Chunks
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.
Chunk Information
One can access information about the current chunk from the global variable 'chunk
'.
X
int
X coordinate in chunk space (world x coordinate divided by chunk size).
Y
int
Y coordinate in chunk space (world y coordinate divided by chunk size).
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 (see below).
Dimension
string
ID of the current dimension.
Initialising a Chunk
You may have noticed the existence of a file called init.lua
in the root of your game's git repository. This should contain a function called init
which is called whenever this chunk is loaded and is designed to initiate the state of this chunk.
Below is the example from the template that comes pre-installed in your repository. You can see that we spawn things only if chunk.Generated
is false, this is to ensure we only spawn things on the first load. However, in a game where state is not persisted (i.e. entities have entity.Transient = true
, this might be useful on every load).
Last updated