Experimental

An early preview: docs, the API and the dashboard may change or break.

Report a problem

types.Chunk

The chunk being generated: 16 by 16 columns from minY up to maxY. Positions are local, x and z 0-15, y in world blocks. It is all air until written, and stale once generate returns.

Fields

chunk.maxY: number
#
read only

One above the highest y in the world.

chunk.minY: number
#
read only

The lowest y in the world.

chunk.x: number
#
read only

The chunk's x, in chunks; its first block is at x * 16.

chunk.z: number
#
read only

The chunk's z, in chunks; its first block is at z * 16.

Methods

chunk:carve(cells: buffer, fromY: number, toY: number, threshold: number, block: number?)
#

Turns every cell above threshold into block (default air), from fromY up to toY. cells holds 256 * (toY - fromY) f32s laid out as Noise:density and gen.interpolate write them.

chunk:column(x: number, z: number, fromY: number, toY: number, block: number)
#

Fills one column from fromY up to, not including, toY.

Range: x: 0..15, z: 0..15

chunk:columns(records: buffer, count: number)
#

Writes count column runs from records, five i32s each: x, z, fromY, toY, block. The fastest way to lay terrain: build every run in Luau, then make one call.

Range: count: 0..65536

chunk:fill(fromY: number, toY: number, block: number)
#

Fills every column from fromY up to, not including, toY. Whole 16-block sections are the cheapest writes there are.

chunk:get(x: number, y: number, z: number) -> number
#

The block at a position in this chunk, as a number; air outside the world's height.

Range: x: 0..15, z: 0..15

chunk:random(salt: string) -> types.Random
#

A random stream of its own for this chunk and salt: the same world seed and chunk give the same numbers.

chunk:set(x: number, y: number, z: number, block: number)
#

Sets one block. x and z from -32 to 47 reach into the neighbouring chunks, which get the block when they generate, or now if they already have; use it for trees and structures that cross the edge. Outside the world's height it does nothing.

Range: x: -32..47, z: -32..47