Kryzeth Standard Library

scripts.things

Methods15

function M.get(thing: things.ThingIdentification) -> things.ThingSummary | nil

Returns the full summary of a Thing

function M.get_thing_id(entity: LuaEntity) -> things.Id | nil

Returns the Thing ID associated with a valid entity

function M.create_thing(params: things.CreateThingParams) -> things.ThingSummary | nil

Creates a Thing from the supplied API parameters

function M.force_destroy(thing: things.ThingIdentification, keep_entity: nil | boolean) -> success boolean

Destroys a Thing and optionally leaves its entity in the world

Parameters
thingthings.ThingIdentification
keep_entitynil | boolean
Returns
successboolean

True when the Things API reports no error

function M.remove_parent(child: things.ThingIdentification) -> success boolean

Removes a Thing from its current parent without destroying it

Parameters
childthings.ThingIdentification
Returns
successboolean

True when the Things API reports no error

function M.add_child(parent: things.ThingIdentification, child_index: string | integer, child: things.ThingIdentification) -> success boolean

Adds an existing child Thing to a parent under the string form of the supplied child index

Parameters
parentthings.ThingIdentification
child_indexstring | integer
childthings.ThingIdentification
Returns
successboolean

True when the Things API reports no error

function M.get_children(parent: things.ThingIdentification) -> things.ThingChildrenSummary | nil

Returns all children registered under a parent Thing

function M.get_child_info(parent: things.ThingIdentification, child_index: string | integer) -> things.ThingSummary | nil

Returns the child summary stored under the string form of a child index

function M.get_child_entity(parent: things.ThingIdentification, child_index: string | integer) -> LuaEntity | nil

Returns the valid child entity stored under a specific child index

function M.get_first_child(parent: things.ThingIdentification) -> LuaEntity | nil

Returns the first valid child entity

function M.get_child_by_type(parent: things.ThingIdentification, entity_type: string) -> LuaEntity | nil

Returns the first valid child entity with the supplied entity type

function M.get_child_by_name(parent: things.ThingIdentification, entity_name: string) -> LuaEntity | nil

Returns the first valid child entity with the supplied entity name

function M.ensure_thing(entity: LuaEntity, thing_name: nil | string) -> things.ThingSummary | nil

Returns the existing Thing summary or creates one for the supplied entity

Parameters
entityLuaEntity
thing_namenil | string

Name used only when a new Thing must be created

Returns
things.ThingSummary | nil
function M.ensure_thing_child(parent: LuaEntity, child_index: string | integer, child: LuaEntity, relative_pos: MapPosition | nil) -> child_info things.ThingSummary | nil

Ensures that an entity is registered as a Thing child at the supplied index Existing void children are filled, incorrect child Things are replaced, and existing Thing entities are moved from their previous parent when required

Parameters
parentLuaEntity
child_indexstring | integer
childLuaEntity
relative_posMapPosition | nil

Position relative to the parent stored by Things

Returns
child_infothings.ThingSummary | nil
function M.get_parent(child: LuaEntity) -> LuaEntity | nil

Returns the valid parent entity of a child Thing

Fields2

M.__class: string = "Things"
M.__index : unknown