Kryzeth Standard Library

entity.entity

Methods13

function Entity.has(entity: LuaEntity, field_name: string) -> boolean

Tests whether an entity has access to a given field.

Parameters
entityLuaEntity

the entity to test the access to a field

field_namestring

the field name

Returns
boolean

true if the entity has access to the field, false if the entity threw an exception when trying to access the field

function Entity.get_data(entity: LuaEntity) -> any

Gets the user data that is associated with an entity. The user data is stored in the storage object and it persists between loads.

The user data will be removed from an entity when the entity becomes invalid.
Parameters
entityLuaEntity

the entity to look up

Returns
any

the user data, or nil if no data exists for the entity

function Entity.set_data(entity: LuaEntity, data: any) -> any

Associates the user data to an entity. The user data will be stored in the storage object and it will persist between loads.

The user data will be removed from an entity when the entity becomes invalid.
Parameters
entityLuaEntity

the entity with which to associate the user data

dataany

the data to set, or nil to delete the data associated with the entity

Returns
any

the previous data associated with the entity, or nil if the entity had no previous data

function Entity.set_frozen(entity: LuaEntity, mode: nil | boolean) -> the LuaEntity

Freezes an entity by disabling it by script and making it inoperable and non-rotatable.

Parameters
entityLuaEntity

the entity to freeze or unfreeze

modenil | boolean

[opt=true] if true, freezes the entity, if false, unfreezes the entity. If not specified, it is set to true

Returns
theLuaEntity

entity that has been frozen or unfrozen

function Entity.set_indestructible(entity: LuaEntity, mode: nil | boolean) -> the LuaEntity

Makes an entity indestructible so that it cannot be damaged or mined neither by the player nor by their enemy factions.

Parameters
entityLuaEntity

the entity to make indestructable

modenil | boolean

[opt=true] if true, makes the entity indestructible, if false, makes the entity destructable

Returns
theLuaEntity

entity that has been made indestructable or destructable

function Entity._are_equal(entity_a: LuaEntity, entity_b: LuaEntity) -> boolean

Tests if two entities are equal. If they don't have a reference equality and *entity_a has **equals* function, it will be called with entity_b** as its first argument.

function Entity.find_resources(entity, all) -> any
function Entity.is_damaged(entity) -> boolean
function Entity.damaged(entity) -> boolean
function Entity.is_circuit_connected(entity) -> any
function Entity.count_circuit_connections(entity) -> integer
function Entity.has_fluidbox(entity) -> boolean
function Entity.can_deconstruct(entity) -> boolean

Fields2

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