1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Document core.MAP_BLOCKSIZE constant in lua_api.md (#15911)

This commit is contained in:
Xiaochuan Ye 2025-03-17 03:02:42 +08:00 committed by GitHub
parent efded8f0bb
commit d085f0fb52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1681,7 +1681,9 @@ roughly 1x1x1 meters in size.
A 'mapblock' (often abbreviated to 'block') is 16x16x16 nodes and is the
fundamental region of a world that is stored in the world database, sent to
clients and handled by many parts of the engine.
clients and handled by many parts of the engine. This size is defined by the constant
`core.MAP_BLOCKSIZE` (=16).
'mapblock' is preferred terminology to 'block' to help avoid confusion with
'node', however 'block' often appears in the API.
@ -1713,7 +1715,7 @@ node position (0,0,0) to node position (15,15,15).
To calculate the blockpos of the mapblock that contains the node at 'nodepos',
for each axis:
* blockpos = math.floor(nodepos / 16)
* blockpos = math.floor(nodepos / core.MAP_BLOCKSIZE)
#### Converting blockpos to min/max node positions
@ -1721,9 +1723,9 @@ To calculate the min/max node positions contained in the mapblock at 'blockpos',
for each axis:
* Minimum:
nodepos = blockpos * 16
nodepos = blockpos * core.MAP_BLOCKSIZE
* Maximum:
nodepos = blockpos * 16 + 15
nodepos = (blockpos + 1) * core.MAP_BLOCKSIZE - 1