Module nodeutil
Various functions related to nodes.
Functions
get_id (node) | Gets the content id of the given node. |
get_name (node) | Gets the name of given node. |
has_group (node, group_name) | Checks if the given node has the given group. |
is_walkable (node) | Checks if the given node is walkable. |
surroundings (pos, x_begin, x_end, z_begin, z_end, y_begin, y_end, callback) | Iterates over the surroundings of the given position and invokes the callback for every node in the surroundings. |
Functions
- get_id (node)
-
Gets the content id of the given node.
Parameters:
- node The node, can either be an id, a name or a table with the name.
Returns:
-
The content id of the given node.
- get_name (node)
-
Gets the name of given node.
Parameters:
- node The node, can either be an id, a name or a table with the name.
Returns:
-
The name of the given node.
- has_group (node, group_name)
-
Checks if the given node has the given group.
Parameters:
- node The node to check.
- group_name The name of the group.
Returns:
-
true if the node has the given group.
- is_walkable (node)
-
Checks if the given node is walkable.
Parameters:
- node The node to check, can either be an id, a name or a table with the name.
Returns:
-
true if the given node is walkable.
- surroundings (pos, x_begin, x_end, z_begin, z_end, y_begin, y_end, callback)
-
Iterates over the surroundings of the given position and invokes
the callback for every node in the surroundings.
For example if you want to iterate over the direct neighbourse in all dimensions, you'd do the following:
nodeutil.surroundings(pos, -1, 1, -1, 1, -1, 1, callback)
Parameters:
- pos The position that is the center.
- x_begin The modifier for the beginning in the x dimension.
- x_end The modifier for the end in the x dimension.
- z_begin The modifier for the beginning in the z dimension.
- z_end The modifier for the end in the z dimension.
- y_begin The modifier for the beginning in the y dimension.
- y_end The modifier for the end in the y dimension.
- callback The callback to invoke for every surrounding node. can return true if iterating over the surroundings should be stopped.
Returns:
-
true if the iterating over the surroundings has been stopped by
a callback.