Home / Region

Other region methods

Region objects also provide the following helpers:

MethodBehavior
region:size()Returns inclusive X, Y and Z sizes.
region:volume()Returns the number of block positions in the region.
region:center()Returns (min + max + 1) / 2 for each axis.
region:intersects(other)Checks whether two region bounds overlap.
region:expand(n [, ny [, nz]])Returns a new region expanded by the supplied distances.
region:entities([kind])Returns entities within the region, optionally filtered by kind.
region:replace(fromId, toId [, metadata])Replaces matching blocks in the region.
region:each(callback)Calls the callback with coordinates and block data for each position. Returning false stops iteration.
region:toTable()Returns a table containing minX/minY/minZ and maxX/maxY/maxZ.

Notes

Region geometry methods are defined in the Farkit Lua bootstrap; entity and block operations they call are part of the bundled Faraway 1.2 extension. Keep iteration and edits bounded because large operations can delay server ticks.