Kryzeth Standard Library

area.chunk

Methods5

function Chunk.to_area(pos: ChunkPosition) -> the BoundingBox

Gets the area of a chunk from the specified chunk position.

Parameters
posChunkPosition

the chunk position

Returns
theBoundingBox

chunk's area

function Chunk.get_data(surface: LuaSurface, chunk_pos: ChunkPosition, default_value: any) -> any

Gets the user data that is associated with a chunk. The user data is stored in the global object and it persists between loads.

Parameters
surfaceLuaSurface

the surface on which the user data is looked up

chunk_posChunkPosition

the chunk position on which the user data is looked up

default_valueany

the user data to set for the chunk and returned if the chunk had no user data

Returns
any

the user data OR nil if it does not exist for the chunk and if no default_value was set

function Chunk.get(surface: LuaSurface, chunk_pos: ChunkPosition, default_value: any) -> any
Parameters
surfaceLuaSurface

the surface on which the user data is looked up

chunk_posChunkPosition

the chunk position on which the user data is looked up

default_valueany

the user data to set for the chunk and returned if the chunk had no user data

Returns
any

the user data OR nil if it does not exist for the chunk and if no default_value was set

function Chunk.set_data(surface: LuaSurface, chunk_pos: ChunkPosition, value: any) -> any

Associates the user data to a chunk. The user data will be stored in the global object and it will persist between loads.

Parameters
surfaceLuaSurface

the surface on which the user data will reside

chunk_posChunkPosition

the chunk position to associate with the user data

valueany

the user data to set OR nil to erase the existing user data for the chunk

Returns
any

the previous user data associated with the chunk OR nil if the chunk had no previous user data

function Chunk.set(surface: LuaSurface, chunk_pos: ChunkPosition, value: any) -> any
Parameters
surfaceLuaSurface

the surface on which the user data will reside

chunk_posChunkPosition

the chunk position to associate with the user data

valueany

the user data to set OR nil to erase the existing user data for the chunk

Returns
any

the previous user data associated with the chunk OR nil if the chunk had no previous user data

Fields5

Chunk.__class: string = "Chunk"
Chunk.__index : unknown
Chunk.__call : any
Chunk.from_position : any

Gets the chunk position of a chunk where the specified position resides. @function Chunk.from_position @see StdLib.Area.Position.tochunkposition

Chunk.to_position : any

Gets the top_left position from a chunk position. @function Chunk.to_position @see StdLib.Area.Position.fromchunkposition