Kryzeth Standard Library

StdLib.Area.Surface

supers: StdLib.Core

For working with surfaces. Surfaces are the "domain" of the world.

See:

LuaSurface

@usage local Surface = require('kry_stdlib/stdlib/area/surface')

Methods4

function Surface.lookup(surface: nil | string | string[] | LuaSurface | LuaSurface[]) -> LuaSurface[]

Flexible and safe lookup function for surfaces. <ul> <li>May be given a single surface name or an array of surface names in @{string}. <li>May be given a single surface object or an array of surface objects in @{LuaSurface}. <li>May also be given a @{nil}. <li>Returns an array of surface objects of all valid and existing surfaces. <li>Returns an empty array if no surfaces are given or if they are not found. </ul>

Parameters
surfacenil | string | string[] | LuaSurface | LuaSurface[]

the surfaces to look up

Returns
LuaSurface[]

an array of all valid surfaces

function Surface.find_all_entities(search_criteria: table) -> LuaEntity[] | nil

Given a @{search_criteria|search criteria}, find all entities that match the criteria. <ul> <li>If *search_criteria.name* is not supplied, search for entities with any name. <li>If *search_criteria.type* is not supplied, search for entities of any type. <li>If *search_criteria.force* is not supplied, search for entities owned by any force. <li>If *search_criteria.surface* is not supplied, search for entities on all surfaces. <li>If *search_criteria.area* is not supplied, search the entire specified surface. </ul> @usage surface.findallentities({ type = 'unit', surface = 'nauvis', area = {{-1000,20},{-153,2214}}) -- returns a list containing all unit entities on the nauvis surface in the given area

Parameters
search_criteriatable

a table used to search for entities

Returns
LuaEntity[] | nil

an array of all entities that matched the criteria OR nil if there were no matches

function Surface.get_surface_bounds(surface: LuaSurface) -> the BoundingBox

Gets the area which covers the entirety of a given surface. This function is useful if you wish to compare the total number of chunks against the number of chunks within the entire area of a given surface.

Parameters
surfaceLuaSurface

the surface for which to get the area

Returns
theBoundingBox

area of a given surface

function Surface.set_daytime_thresholds(surface: LuaSurface, morning: number, dawn: number, dusk: number, evening: number) -> boolean

Sets the daytime transition thresholds on a given surface

Parameters
surfaceLuaSurface

the surface for which to set the thresholds

morningnumber

daytime to begin transition from dark to light

dawnnumber

daytime to finish transition from dark to light

dusknumber

daytime to begin transition from light to dark

eveningnumber

daytime to finish transition from light to dark

Returns
boolean

true if the thresholds were set, false if there was an error @return[opt] the raised error, if any

Fields2

Surface.__class: string = "Surface"
Surface.__index : unknown