StdLib.Area.Chunk
A chunk represents a 32 tile<sup>2</sup> on a surface in Factorio.
ChunkPosition
@usage local Chunk = require('kry_stdlib/stdlib/area/chunk')
Methods5
function Chunk.to_area(pos: ChunkPosition) -> the BoundingBox
Gets the area of a chunk from the specified chunk position.
posChunkPositionthe chunk position
theBoundingBoxchunk'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.
surfaceLuaSurfacethe surface on which the user data is looked up
chunk_posChunkPositionthe chunk position on which the user data is looked up
default_valueanythe user data to set for the chunk and returned if the chunk had no user data
- 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
surfaceLuaSurfacethe surface on which the user data is looked up
chunk_posChunkPositionthe chunk position on which the user data is looked up
default_valueanythe user data to set for the chunk and returned if the chunk had no user data
- 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.
surfaceLuaSurfacethe surface on which the user data will reside
chunk_posChunkPositionthe chunk position to associate with the user data
valueanythe user data to set OR nil to erase the existing user data for the chunk
- 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
surfaceLuaSurfacethe surface on which the user data will reside
chunk_posChunkPositionthe chunk position to associate with the user data
valueanythe user data to set OR nil to erase the existing user data for the chunk
- 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