returns true if passed 'y', 'yes', 'true' or a number that isn't zero.
arg is converted to a string first, case and surrounding whitespace
are ignored.
core.is_nan(arg)
returns true when the passed number represents NaN.
core.get_us_time()
returns time in microseconds since an unspecified starting point
(usually not wall time)
only useful for measuring elapsed time
table.copy(table): returns a table
returns a deep copy of table
strips metatables, but this may change in the future
table.copy_with_metatables(table)
since 5.12
table can also be non-table value, which will be returned as-is
preserves metatables as they are
table.indexof(list, val): returns the smallest numerical index containing
the value val in the table list. Non-numerical indices are ignored.
If val could not be found, -1 is returned. list must not have
negative indices. The search stops at the first nil value.
table.keyof(table, val): returns the key containing
the value val in the table table. If multiple keys contain val,
it is unspecified which key will be returned.
If val could not be found, nil is returned.
table.insert_all(table, other_table):
Appends all values in other_table to table - uses #table + 1 to
find new indices.
Returns table.
table.key_value_swap(t): returns a table with keys and values swapped
If multiple keys in t map to the same value, it is unspecified which
value maps to that key.
random_func defaults to math.random. This function receives two
integers as arguments and should return a random integer inclusively
between them.
core.pointed_thing_to_face_pos(placer, pointed_thing): returns a
position.
returns the exact position on the surface of a pointed node
placer: ObjectRef of a player
pointed_thing: must be of type "node"
core.get_tool_wear_after_use(uses, initial_wear)
Simulates a tool being used once and returns the added wear,
such that, if only this function is used to calculate wear,
the tool will break exactly after uses times of uses
uses: Amount of times the tool can be used
If 0, the tool has infinite uses and 0 is returned.
initial_wear: The initial wear the tool starts with (default: 0)
core.get_dig_params(groups, tool_capabilities, wear):
Simulates an item that digs a node.
Returns a table with the following fields:
diggable: true if node can be dug, false otherwise.
time: Time in seconds it would take to dig the node.
wear: How much wear would be added to the tool (ignored for non-tools).
time and wear are meaningless if node's not diggable
Parameters:
groups: Table of the node groups of the node that would be dug
tool_capabilities: Tool capabilities table of the item
wear: Amount of wear the tool starts with (default: 0)
core.get_hit_params(groups, tool_capabilities, time_from_last_punch, wear):
Simulates an item that punches an object.
Returns a table with the following fields:
hp: How much damage the punch would cause; integer in range [-65535, 65535].
wear: How much wear would be added to the tool (ignored for non-tools).
Parameters:
groups: Damage groups of the object
tool_capabilities: Tool capabilities table of the item
time_from_last_punch: time in seconds since last punch action.
If nil, full damage is assumed.
wear: Amount of wear the item starts with (default: 0)