Chunks
Last updated
Last updated
Planetary Processing works by dividing your world into chunks. Chunks are cuboid segments of the world of fixed width and depth, and of infinite height.
ID
int
ID of the chunk
X
int
X coordinate in chunk space.
Y
int
Y coordinate in chunk space.
Size
int
Size of the chunk in world units.
Generated
bool
Indicates whether or not this chunk has been loaded before. This should not be used outside of the init
function.
Dimension
string
ID of the current dimension.
Data
table
Custom lua table which can be used to store arbitrary data about the chunk, such as heightmap or other terrain info, for example.
Init
None
None
A necessary function, which runs whenever a chunk loads.
Every game world requires a file called init.lua
in the root of your game's repository. This file contains your chunk code.
The init.lua
file only has one function called which is called whenever this chunk is loaded and is designed to initiate the state of this chunk.
Every chunk has an and value, based on its position in the world. The exact boundaries of the chunk are defined by the . Multiplying each chunk coordinate value by the will give a point position at the bottom left corner of that chunk, in terms of the game's world coordinates.
The function triggers every time a chunk loads or reloads. This will happen whenever a player or entity comes near it. This means the code will often be triggered multiple times, over the course of a game world's lifetime.
The field of a chunk allows you to distinguish whether it is loading for the first time, or has been generated before and is reloading. This is useful if you want to spawn or setup your world in a specific way when it is first generated.
Information about the current chunk can be accessed from the global variable . Entities within the chunk and the chunk itself both have access to this information.