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 Creation
Every game world requires a file called init.lua in the root of your game's git repository. This file contains your chunk code.
Init
The init.lua file only has one function called init which is called whenever this chunk is loaded and is designed to initiate the state of this chunk.
Chunk Size and Coordinates
Every chunk has an X and Y value, based on its position in the world. The exact boundaries of the chunk are defined by the Chunk Size. Multiplying each chunk coordinate value by the Chunk Size will give a point position at the bottom left corner of that chunk, in terms of the game's world coordinates.

World Generation
The init function triggers every time a chunk loads or reloads. This will happen when the game starts or whenever a player comes near it. This means the init code will often be triggered multiple times, over the course of a game world's lifetime.
The Generated 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.
Chunk API
Information about the current chunk can be accessed from the global variable chunk. Entities within the chunk and the chunk itself both have access to this information.
Chunk
Init
Last updated