Tools for working with entities.
local Entity = require('__stdlib__/stdlib/entity/entity')
has(entity, field_name) | Tests whether an entity has access to a given field. |
get_data(entity) | Gets the user data that is associated with an entity. |
set_data(entity, data) | Associates the user data to an entity. |
set_frozen(entity[, mode=true]) | Freezes an entity, by making it inactive, inoperable, and non-rotatable, or unfreezes by doing the reverse. |
set_indestructible(entity[, mode=true]) | Makes an entity indestructible so that it cannot be damaged or mined neither by the player nor by their enemy factions. |
_are_equal(entity_a, entity_b) | Tests if two entities are equal. |
destroy_entity(entity[, died=false][, cause][, force]) | Destroy an entity by first raising the event. |
create_entity(surface, settings[, player_index][, raise_script_event]) | Create an entity and raise a build event. |
revive(ghost[, player_index][, raise_script_event]) | Revivie an entity ghost and raise the on_built or on_robot_built event. |
Tests whether an entity has access to a given field.
Parameters: Returns:
Gets the user data that is associated with an entity.
The user data is stored in the global object and it persists between loads.
Parameters:The user data will be removed from an entity when the entity becomes invalid.
Associates the user data to an entity.
The user data will be stored in the global object and it will persist between loads.
Parameters:The user data will be removed from an entity when the entity becomes invalid.
Freezes an entity, by making it inactive, inoperable, and non-rotatable, or unfreezes by doing the reverse.
Parameters:
Makes an entity indestructible so that it cannot be damaged or mined neither by the player nor by their enemy factions.
Parameters:
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.
Parameters: Returns:Destroy an entity by first raising the event.
Parameters:Some entities can't be destroyed, such as the rails with trains on them.
Create an entity and raise a build event.
Parameters:
Revivie an entity ghost and raise the on_built
or on_robot_built
event.
Parameters: Returns: