Module:Common/doc

From Noita Wiki
Jump to navigation Jump to search

This is the documentation page for Module:Common

This module provides commonly required Lua functions, which are not provided by the standard library. It is intended to be used by other Lua modules on the wiki.

Functions

Function Return type Parameter1 Parameter2 Parameter3 Description
isEmpty bool any type Return true if the value is null, or when the type is string and the value is empty.
string.parseInt number string Get the first integer number from a string.
string.parseFloat number string Get the first floating point number from a string.
string.split table string:input string:delimeter (optional) The input string is split into a table when any of the delimeter characters are met. The default delimeter is ,%c, the string is split at comma or control characters (tabs, new lines, etc.).
string.trim string string Trim away leading and trailing whitespace from string.
table.merge table table:to table:from bool:append_ipairs (optional) Replace matching key value pairs in table:to with items from table:from. When bool:append_ipairs is set to true, number indexed pairs are appended into table:to. By default number indexed pairs are replaced.
table.mergeDeep table table:to table:from bool:append_ipairs (optional) Same as table.merge, except with this function all child tables are recursively merged as well, instead of replaced.
table.removeEmpty table table Remove all null or empty key value pairs from the table.
table.trimTable table table Trim all strings in the table.
formatNum string number number_k (optional) number_M (optional) number_k (Default value 4) and number_M (Default value 6) determine how many digits are required before appending the 'k' and 'M' prefixes.
With a value of 4 for number_k the 'k' prefix is not used with 4 digit numbers, since it would take more screen space to show a less accurate number (1234 vs 1.23k)