Module util
utilities and helpers
Functions
mapblock_lib.get_mapblock_center (pos) | returns the mapblock-center of the given coordinates |
mapblock_lib.get_mapblock (pos) | returns the mapblock position for the node-position |
mapblock_lib.is_mapblock_aligned (pos1, pos2) | returns true if the two positions align to a single mapblock's edges |
mapblock_lib.get_mapblock_bounds_from_mapblock (block_pos) | returns the max/min bounds for the mapblock-position |
mapblock_lib.get_mapblock_bounds (pos) | returns the max/min bounds for the node-position |
mapblock_lib.sort_pos (pos1, pos2) | sorts the position by ascending order |
mapblock_lib.pos_iterator (pos1, pos2) | returns an iterator function for the mapblock coordinate range |
mapblock_lib.for_each (pos1, pos2, fn) | iterate through the specified region |
mapblock_lib.clear_mapblock (mapblock_pos) | clears a mapblock (fills it with air) |
mapblock_lib.rotate_pos (rel_pos, max, rotation_y) | rotate a position around the y axis |
mapblock_lib.rotate_size (size, rotation_y) | rotate a size vector |
Tables
mapblock_pos | Mapblock position |
node_pos | Node position |
Functions
- mapblock_lib.get_mapblock_center (pos)
-
returns the mapblock-center of the given coordinates
Parameters:
- pos node_pos the node-position
Returns:
-
node_pos the node-position of the current mapblock-center with fractions
- mapblock_lib.get_mapblock (pos)
-
returns the mapblock position for the node-position
Parameters:
- pos node_pos the node-position
Returns:
-
mapblock_pos the mapblock-position
- mapblock_lib.is_mapblock_aligned (pos1, pos2)
-
returns true if the two positions align to a single mapblock's edges
Parameters:
- mapblock_lib.get_mapblock_bounds_from_mapblock (block_pos)
-
returns the max/min bounds for the mapblock-position
Parameters:
- block_pos mapblock_pos the mapblock-position
Returns:
- mapblock_lib.get_mapblock_bounds (pos)
-
returns the max/min bounds for the node-position
Parameters:
- pos node_pos the node-position
Returns:
- mapblock_lib.sort_pos (pos1, pos2)
-
sorts the position by ascending order
Parameters:
Returns:
- mapblock_lib.pos_iterator (pos1, pos2)
-
returns an iterator function for the mapblock coordinate range
Parameters:
- pos1 mapblock_pos the lower position
- pos2 mapblock_pos the upper position
Returns:
- a position iterator
- the total node/mapblock count
- mapblock_lib.for_each (pos1, pos2, fn)
-
iterate through the specified region
Parameters:
- pos1 mapblock_pos the lower position
- pos2 mapblock_pos the upper position
- fn the position callback
- mapblock_lib.clear_mapblock (mapblock_pos)
-
clears a mapblock (fills it with air)
Parameters:
- mapblock_pos the mapblock position
- mapblock_lib.rotate_pos (rel_pos, max, rotation_y)
-
rotate a position around the y axis
Parameters:
- rel_pos node_pos the relative position to rotate
- max node_pos the maximum position to rotate in
- rotation_y the clock-wise rotation, either 0,90,180 or 270
Returns:
-
node_pos the rotated position
- mapblock_lib.rotate_size (size, rotation_y)
-
rotate a size vector
Parameters:
- size node_pos a size vector
- rotation_y the clock-wise rotation, either 0,90,180 or 270
Returns:
-
node_pos the rotated size