Factorio Runtime DocsVersion 2.0.19

ClassLuaEntityextendsLuaControlchanged

The primary interface for interacting with entities through the Lua API. Entities are everything that exists on the map except for tiles (see LuaTile).

Most functions on LuaEntity also work when the entity is contained in a ghost.

Members

get_output_inventory() LuaInventory?

Gets the entity's output inventory if it has one.

Gets the entity's output inventory if it has one.

get_module_inventory() LuaInventory?

Inventory for storing modules of this entity; nil if this entity has no module inventory.

Inventory for storing modules of this entity; nil if this entity has no module inventory.

get_fuel_inventory() LuaInventory?

The fuel inventory for this entity or nil if this entity doesn't have a fuel inventory.

The fuel inventory for this entity or nil if this entity doesn't have a fuel inventory.

get_burnt_result_inventory() LuaInventory?

The burnt result inventory for this entity or nil if this entity doesn't have a burnt result inventory.

The burnt result inventory for this entity or nil if this entity doesn't have a burnt result inventory.

damage(damage, force, type?, source?, cause?) changedfloat

Damages the entity.

Damages the entity.

can_be_destroyed() boolean

Whether the entity can be destroyed

Whether the entity can be destroyed

destroy{do_cliff_correction?=…, raise_destroy?=…, player?=…, item_index?=…} changedboolean

Destroys the entity. [...]

Destroys the entity. [...]

die(force?, cause?) changedboolean

Immediately kills the entity. [...]

Immediately kills the entity. [...]

has_flag(flag) boolean

Test whether this entity's prototype has a certain flag set. [...]

Test whether this entity's prototype has a certain flag set. [...]

ghost_has_flag(flag) boolean

Same as LuaEntity::has_flag, but targets the inner entity on a entity ghost.

Same as LuaEntity::has_flag, but targets the inner entity on a entity ghost.

add_market_item(offer)

Offer a thing on the market.

Offer a thing on the market.

remove_market_item(offer) boolean

Remove an offer from a market. [...]

Remove an offer from a market. [...]

get_market_items() → array[Offer]

Get all offers in a market as an array.

Get all offers in a market as an array.

clear_market_items()

Removes all offers from a market.

Removes all offers from a market.

order_deconstruction(force, player?, item_index?) changedboolean

Sets the entity to be deconstructed by construction robots.

Sets the entity to be deconstructed by construction robots.

cancel_deconstruction(force, player?) changed

Cancels deconstruction if it is scheduled, does nothing otherwise.

Cancels deconstruction if it is scheduled, does nothing otherwise.

to_be_deconstructed() boolean

Is this entity marked for deconstruction?

Is this entity marked for deconstruction?

order_upgrade{target=…, force=…, player?=…, item_index?=…} changedboolean

Sets the entity to be upgraded by construction robots.

Sets the entity to be upgraded by construction robots.

cancel_upgrade(force, player?) changedboolean

Cancels upgrade if it is scheduled, does nothing otherwise.

Cancels upgrade if it is scheduled, does nothing otherwise.

to_be_upgraded() boolean

Is this entity marked for upgrade?

Is this entity marked for upgrade?

is_crafting() boolean

Returns whether a craft is currently in process. [...]

Returns whether a craft is currently in process. [...]

is_opened() boolean
is_opening() boolean
is_closed() boolean
is_closing() boolean
request_to_open(force, extra_time?) changed
request_to_close(force) changed
get_transport_line(index) LuaTransportLine

Get a transport line of a belt or belt connectable entity.

Get a transport line of a belt or belt connectable entity.

get_item_insert_specification(position) newuint, float

Get an item insert specification onto a belt connectable: for a given map position provides into which line at what position item should be inserted to be closest to the provided position.

Get an item insert specification onto a belt connectable: for a given map position provides into which line at what position item should be inserted to be closest to the provided position.

get_line_item_position(index, position) newMapPosition

Get a map position related to a position on a transport line.

Get a map position related to a position on a transport line.

get_max_transport_line_index() uint

Get the maximum transport line index of a belt or belt connectable entity.

Get the maximum transport line index of a belt or belt connectable entity.

launch_rocket() boolean
revive{return_item_request_proxy?=…, raise_revive?=…} → dictionary[string → uint]?, LuaEntity?, LuaEntity?

Revive a ghost, which turns it from a ghost into a real entity or tile.

Revive a ghost, which turns it from a ghost into a real entity or tile.

silent_revive{raise_revive?=…} changed → array[ItemCountWithQuality], LuaEntity?, LuaEntity?

Revives a ghost silently, so the revival makes no sound and no smoke is created.

Revives a ghost silently, so the revival makes no sound and no smoke is created.

get_connected_rail{rail_direction=…, rail_connection_direction=…} LuaEntity?, defines.rail_direction?, defines.rail_connection_direction?
get_connected_rails() → array[LuaEntity]

Get the rails that this signal is connected to.

Get the rails that this signal is connected to.

get_rail_segment_signal(direction, in_else_out) newLuaEntity?

Get the rail signal at the start/end of the rail segment this rail is in. [...]

Get the rail signal at the start/end of the rail segment this rail is in. [...]

get_rail_segment_stop(direction) newLuaEntity?

Get train stop at the start/end of the rail segment this rail is in. [...]

Get train stop at the start/end of the rail segment this rail is in. [...]

get_rail_segment_end(direction) LuaEntity, defines.rail_direction

Get the rail at the end of the rail segment this rail is in. [...]

Get the rail at the end of the rail segment this rail is in. [...]

get_rail_segment_rails(direction) → array[LuaEntity]

Get all rails of a rail segment this rail is in

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Get all rails of a rail segment this rail is in

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

get_rail_segment_length() double

Get the length of the rail segment this rail is in. [...]

Get the length of the rail segment this rail is in. [...]

get_rail_segment_overlaps() → array[LuaEntity]

Get a rail from each rail segment that overlaps with this rail's rail segment. [...]

Get a rail from each rail segment that overlaps with this rail's rail segment. [...]

is_rail_in_same_rail_segment_as(other_rail) boolean

Checks if this rail and other rail both belong to the same rail segment.

Checks if this rail and other rail both belong to the same rail segment.

is_rail_in_same_rail_block_as(other_rail) boolean

Checks if this rail and other rail both belong to the same rail block.

Checks if this rail and other rail both belong to the same rail block.

get_parent_signals() → array[LuaEntity]

Returns all parent signals. [...]

Returns all parent signals. [...]

get_child_signals() → array[LuaEntity]

Returns all child signals. [...]

Returns all child signals. [...]

get_inbound_signals() → array[LuaEntity]

Returns all signals guarding entrance to a rail block this rail belongs to.

Returns all signals guarding entrance to a rail block this rail belongs to.

get_outbound_signals() → array[LuaEntity]

Returns all signals guarding exit from a rail block this rail belongs to.

Returns all signals guarding exit from a rail block this rail belongs to.

get_filter(slot_index) changedItemFilter?

Get the filter for a slot in an inserter, loader, or logistic storage container. [...]

Get the filter for a slot in an inserter, loader, or logistic storage container. [...]

set_filter(index, filter?) changed

Set the filter for a slot in an inserter (ItemFilter), loader (ItemFilter), mining drill (EntityID) or logistic storage container (ItemWithQualityID). [...]

Set the filter for a slot in an inserter (ItemFilter), loader (ItemFilter), mining drill (EntityID) or logistic storage container (ItemWithQualityID). [...]

get_infinity_container_filter(index) InfinityInventoryFilter?

Gets the filter for this infinity container at the given index, or nil if the filter index doesn't exist or is empty.

Gets the filter for this infinity container at the given index, or nil if the filter index doesn't exist or is empty.

set_infinity_container_filter(index, filter)

Sets the filter for this infinity container at the given index.

Sets the filter for this infinity container at the given index.

get_infinity_pipe_filter() InfinityPipeFilter?

Gets the filter for this infinity pipe, or nil if the filter is empty.

Gets the filter for this infinity pipe, or nil if the filter is empty.

set_infinity_pipe_filter(filter)

Sets the filter for this infinity pipe.

Sets the filter for this infinity pipe.

get_heat_setting() HeatSetting

Gets the heat setting for this heat interface.

Gets the heat setting for this heat interface.

set_heat_setting(filter)

Sets the heat setting for this heat interface.

Sets the heat setting for this heat interface.

get_control_behavior() LuaControlBehavior?

Gets the control behavior of the entity (if any).

Gets the control behavior of the entity (if any).

get_or_create_control_behavior() LuaControlBehavior?

Gets (and or creates if needed) the control behavior of the entity.

Gets (and or creates if needed) the control behavior of the entity.

get_circuit_network(wire_connector_id) changedLuaCircuitNetwork?
get_signal(signal, wire_connector_id, extra_wire_connector_id?) newint

Read a single signal from the selected wire connector

Read a single signal from the selected wire connector

get_signals(wire_connector_id, extra_wire_connector_id?) new → array[Signal]?

Read all signals from the selected wire connector.

Read all signals from the selected wire connector.

supports_backer_name() boolean

Whether this entity supports a backer name.

Whether this entity supports a backer name.

copy_settings(entity, by_player?) changed → array[ItemCountWithQuality]

Copies settings from the given entity onto this entity.

Copies settings from the given entity onto this entity.

get_logistic_point(index?) LuaLogisticPoint or dictionary[defines.logistic_member_index → LuaLogisticPoint]?

Gets all the LuaLogisticPoints that this entity owns. [...]

Gets all the LuaLogisticPoints that this entity owns. [...]

play_note(instrument, note) boolean

Plays a note with the given instrument and note.

Plays a note with the given instrument and note.

connect_rolling_stock(direction) boolean

Connects the rolling stock in the given direction.

Connects the rolling stock in the given direction.

disconnect_rolling_stock(direction) boolean

Tries to disconnect this rolling stock in the given direction.

Tries to disconnect this rolling stock in the given direction.

update_connections()

Reconnect loader, beacon, cliff and mining drill connections to entities that might have been teleported out or in by the script. [...]

Reconnect loader, beacon, cliff and mining drill connections to entities that might have been teleported out or in by the script. [...]

get_recipe() changedLuaRecipe?, LuaQualityPrototype?

Current recipe being assembled by this machine, if any.

Current recipe being assembled by this machine, if any.

set_recipe(recipe?, quality?) changed → array[ItemCountWithQuality]

Sets the given recipe in this assembly machine.

Sets the given recipe in this assembly machine.

rotate{reverse?=…, by_player?=…} changedboolean

Rotates this entity as if the player rotated it.

Rotates this entity as if the player rotated it.

get_driver() LuaEntity or LuaPlayer?

Gets the driver of this vehicle if any.

Gets the driver of this vehicle if any.

set_driver(driver?)

Sets the driver of this vehicle. [...]

Sets the driver of this vehicle. [...]

get_passenger() LuaEntity or LuaPlayer?

Gets the passenger of this car or spidertron if any. [...]

Gets the passenger of this car or spidertron if any. [...]

set_passenger(passenger?)

Sets the passenger of this car or spidertron. [...]

Sets the passenger of this car or spidertron. [...]

is_connected_to_electric_network() boolean

Returns true if this entity produces or consumes electricity and is connected to an electric network that has at least one entity that can produce power.

Returns true if this entity produces or consumes electricity and is connected to an electric network that has at least one entity that can produce power.

get_train_stop_trains() → array[LuaTrain]

The trains scheduled to stop at this train stop.

The trains scheduled to stop at this train stop.

get_stopped_train() LuaTrain?

The train currently stopped at this train stop, if any.

The train currently stopped at this train stop, if any.

clone{position=…, surface?=…, force?=…, create_build_effect_smoke?=…} changedLuaEntity?

Clones this entity.

Clones this entity.

get_fluid_count(fluid?) double

Get the amount of all or some fluid in this entity. [...]

Get the amount of all or some fluid in this entity. [...]

get_fluid_contents() → dictionary[string → double]

Get amounts of all fluids in this entity. [...]

Get amounts of all fluids in this entity. [...]

remove_fluid{name=…, amount=…, minimum_temperature?=…, maximum_temperature?=…, temperature?=…} double

Remove fluid from this entity. [...]

Remove fluid from this entity. [...]

insert_fluid(fluid) double

Insert fluid into this entity. [...]

Insert fluid into this entity. [...]

clear_fluid_inside()

Remove all fluids from this entity.

Remove all fluids from this entity.

get_beam_source() BeamTarget?

Get the source of this beam.

Get the source of this beam.

set_beam_source(source)

Set the source of this beam.

Set the source of this beam.

get_beam_target() BeamTarget?

Get the target of this beam.

Get the target of this beam.

set_beam_target(target)

Set the target of this beam.

Set the target of this beam.

get_radius() double

The radius of this entity.

The radius of this entity.

get_health_ratio() float?

The health ratio of this entity between 1 and 0 (for full health and no health respectively).

The health ratio of this entity between 1 and 0 (for full health and no health respectively).

create_build_effect_smoke()

Creates the same smoke that is created when you place a building by hand. [...]

Creates the same smoke that is created when you place a building by hand. [...]

release_from_spawner()

Release the unit from the spawner which spawned it. [...]

Release the unit from the spawner which spawned it. [...]

toggle_equipment_movement_bonus()

Toggle this entity's equipment movement bonus. [...]

Toggle this entity's equipment movement bonus. [...]

can_shoot(target, position) boolean

Whether this character can shoot the given entity or position.

Whether this character can shoot the given entity or position.

start_fading_out()

Only works if the entity is a speech-bubble, with an "effect" defined in its wrapper_flow_style. [...]

Only works if the entity is a speech-bubble, with an "effect" defined in its wrapper_flow_style. [...]

get_upgrade_target() changedLuaEntityPrototype?, LuaQualityPrototype?

Returns the new entity prototype and its quality.

Returns the new entity prototype and its quality.

get_damage_to_be_taken() float?

Returns the amount of damage to be taken by this entity.

Returns the amount of damage to be taken by this entity.

deplete()

Depletes and destroys this resource entity.

Depletes and destroys this resource entity.

mine{inventory?=…, force?=…, raise_destroyed?=…, ignore_minable?=…} boolean

Mines this entity. [...]

Mines this entity. [...]

spawn_decorations()

Triggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or "unit-spawner".

Triggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or "unit-spawner".

get_priority_target(index) newLuaEntityPrototype?

Get the entity ID at the specified position in the turret's priority list.

Get the entity ID at the specified position in the turret's priority list.

set_priority_target(index, entity_id?) new

Set the entity ID name at the specified position in the turret's priority list.

Set the entity ID name at the specified position in the turret's priority list.

can_wires_reach(entity) boolean

Can wires reach between these entities.

Can wires reach between these entities.

get_connected_rolling_stock(direction) LuaEntity?, defines.rail_direction?

Gets rolling stock connected to the given end of this stock.

Gets rolling stock connected to the given end of this stock.

is_registered_for_construction() boolean

Is this entity or tile ghost or item request proxy registered for construction? [...]

Is this entity or tile ghost or item request proxy registered for construction? [...]

is_registered_for_deconstruction(force) changedboolean

Is this entity registered for deconstruction with this force? [...]

Is this entity registered for deconstruction with this force? [...]

is_registered_for_upgrade() boolean

Is this entity registered for upgrade? [...]

Is this entity registered for upgrade? [...]

is_registered_for_repair() boolean

Is this entity registered for repair? [...]

Is this entity registered for repair? [...]

add_autopilot_destination(position)

Adds the given position to this spidertron's autopilot's queue of destinations.

Adds the given position to this spidertron's autopilot's queue of destinations.

connect_linked_belts(neighbour?)

Connects current linked belt with another one. [...]

Connects current linked belt with another one. [...]

disconnect_linked_belts()

Disconnects linked belt from its neighbour. [...]

Disconnects linked belt from its neighbour. [...]

get_spider_legs() → array[LuaEntity]

Gets legs of given SpiderVehicle.

Gets legs of given SpiderVehicle.

stop_spider()

Sets the speed of the given SpiderVehicle to zero. [...]

Sets the speed of the given SpiderVehicle to zero. [...]

get_wire_connector(wire_connector_id, or_create) newLuaWireConnector

Gets a single wire connector of this entity

Gets a single wire connector of this entity

get_wire_connectors(or_create) new → dictionary[defines.wire_connector_id → LuaWireConnector]

Gets all wire connectors of this entity

Gets all wire connectors of this entity

get_rail_end(direction) newLuaRailEnd

Gets a LuaRailEnd object for specified end of this rail

Gets a LuaRailEnd object for specified end of this rail

get_electric_input_flow_limit(quality?) newdouble?

The input flow limit for the electric energy source. [...]

The input flow limit for the electric energy source. [...]

get_electric_output_flow_limit(quality?) newdouble?

The output flow limit for the electric energy source. [...]

The output flow limit for the electric energy source. [...]

get_beacons() → array[LuaEntity]?

Returns a table with all beacons affecting this effect receiver. [...]

Returns a table with all beacons affecting this effect receiver. [...]

get_beacon_effect_receivers() → array[LuaEntity]

Returns a table with all entities affected by this beacon

Returns a table with all entities affected by this beacon

force_finish_ascending() new

Take an ascending cargo pod and safely make it skip all animation and immediately switch surface.

Take an ascending cargo pod and safely make it skip all animation and immediately switch surface.

force_finish_descending() new

Take a descending cargo pod and safely make it arrive and deposit cargo.

Take a descending cargo pod and safely make it arrive and deposit cargo.

get_fluid(index) newFluid?

Gets fluid of the i-th fluid storage.

Gets fluid of the i-th fluid storage.

set_fluid(index, fluid?) newFluid?

Sets fluid to the i-th fluid storage. [...]

Sets fluid to the i-th fluid storage. [...]

get_logistic_sections() newLuaLogisticSections?

Gives logistic sections of this entity if it uses logistic sections.

Gives logistic sections of this entity if it uses logistic sections.

name :: R string

Name of the entity prototype. [...]

Name of the entity prototype. [...]

ghost_name :: R string

Name of the entity or tile contained in this ghost

Name of the entity or tile contained in this ghost

localised_name :: R LocalisedString

Localised name of the entity.

Localised name of the entity.

localised_description :: R LocalisedString
ghost_localised_name :: R LocalisedString

Localised name of the entity or tile contained in this ghost.

Localised name of the entity or tile contained in this ghost.

ghost_localised_description :: R LocalisedString
type :: R string

The entity prototype type of this entity.

The entity prototype type of this entity.

ghost_type :: R string

The prototype type of the entity or tile contained in this ghost.

The prototype type of the entity or tile contained in this ghost.

use_filters new :: RW boolean

If set to 'true', this inserter will use filtering logic. [...]

If set to 'true', this inserter will use filtering logic. [...]

active :: RW boolean

Deactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will stop moving etc). [...]

Deactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will stop moving etc). [...]

destructible :: RW boolean

If set to false, this entity can't be damaged and won't be attacked automatically. [...]

If set to false, this entity can't be damaged and won't be attacked automatically. [...]

minable :: RW boolean

Not minable entities can still be destroyed. [...]

Not minable entities can still be destroyed. [...]

rotatable :: RW boolean

When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key. [...]

When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key. [...]

operable :: RW boolean

Player can't open gui of this entity and he can't quick insert/input stuff in to the entity when it is not operable.

Player can't open gui of this entity and he can't quick insert/input stuff in to the entity when it is not operable.

health :: RW float?

The current health of the entity, if any. [...]

The current health of the entity, if any. [...]

max_health new :: R float

Max health of this entity.

Max health of this entity.

direction :: RW defines.direction

The current direction this entity is facing.

The current direction this entity is facing.

mirroring new :: RW boolean

If the entity is currently mirrored.

If the entity is currently mirrored.

supports_direction :: R boolean

Whether the entity has direction. [...]

Whether the entity has direction. [...]

orientation :: RW RealOrientation

The smooth orientation of this entity.

The smooth orientation of this entity.

cliff_orientation :: R CliffOrientation

The orientation of this cliff.

The orientation of this cliff.

relative_turret_orientation :: RW RealOrientation?

The relative orientation of the vehicle turret, artillery turret, artillery wagon. [...]

The relative orientation of the vehicle turret, artillery turret, artillery wagon. [...]

torso_orientation :: RW RealOrientation

The torso orientation of this spider vehicle.

The torso orientation of this spider vehicle.

amount :: RW uint

Count of resource units contained.

Count of resource units contained.

initial_amount :: RW uint?

Count of initial resource units contained. [...]

Count of initial resource units contained. [...]

effectivity_modifier :: RW float

Multiplies the acceleration the vehicle can create for one unit of energy. [...]

Multiplies the acceleration the vehicle can create for one unit of energy. [...]

consumption_modifier :: RW float

Multiplies the energy consumption.

Multiplies the energy consumption.

friction_modifier :: RW float

Multiplies the car friction rate.

Multiplies the car friction rate.

driver_is_gunner :: RW boolean?

Whether the driver of this car or spidertron is the gunner. [...]

Whether the driver of this car or spidertron is the gunner. [...]

vehicle_automatic_targeting_parameters :: RW VehicleAutomaticTargetingParameters

Read when this spidertron auto-targets enemies

Read when this spidertron auto-targets enemies

speed :: RW float?

The current speed if this is a car, rolling stock, projectile or spidertron, or the maximum speed if this is a unit. [...]

The current speed if this is a car, rolling stock, projectile or spidertron, or the maximum speed if this is a unit. [...]

effective_speed :: R float?

The current speed of this unit in tiles per tick, taking into account any walking speed modifier given by the tile the unit is standing on. [...]

The current speed of this unit in tiles per tick, taking into account any walking speed modifier given by the tile the unit is standing on. [...]

stack :: R LuaItemStack
prototype :: R LuaEntityPrototype

The entity prototype of this entity.

The entity prototype of this entity.

ghost_prototype :: R LuaEntityPrototype or LuaTilePrototype

The prototype of the entity or tile contained in this ghost.

The prototype of the entity or tile contained in this ghost.

drop_position :: RW MapPosition

Position where the entity puts its stuff. [...]

Position where the entity puts its stuff. [...]

pickup_position :: RW MapPosition

Where the inserter will pick up items from. [...]

Where the inserter will pick up items from. [...]

drop_target :: RW LuaEntity?

The entity this entity is putting its items to. [...]

The entity this entity is putting its items to. [...]

pickup_target :: RW LuaEntity?

The entity this inserter will attempt to pick up items from. [...]

The entity this inserter will attempt to pick up items from. [...]

selected_gun_index :: RW uint?

Index of the currently selected weapon slot of this character, car, or spidertron. [...]

Index of the currently selected weapon slot of this character, car, or spidertron. [...]

energy :: RW double

Energy stored in the entity's energy buffer (energy stored in electrical devices etc.). [...]

Energy stored in the entity's energy buffer (energy stored in electrical devices etc.). [...]

temperature :: RW double?

The temperature of this entity's heat energy source. [...]

The temperature of this entity's heat energy source. [...]

previous_recipe changed :: R RecipeIDAndQualityIDPair?

The previous recipe this furnace was using, if any.

The previous recipe this furnace was using, if any.

held_stack :: R LuaItemStack

The item stack currently held in an inserter's hand.

The item stack currently held in an inserter's hand.

held_stack_position :: R MapPosition

Current position of the inserter's "hand".

Current position of the inserter's "hand".

train :: R LuaTrain?

The train this rolling stock belongs to, if any. [...]

The train this rolling stock belongs to, if any. [...]

neighbours :: R dictionary[string → array[LuaEntity]] or array[array[LuaEntity]] or LuaEntity?

A list of neighbours for certain types of entities. [...]

A list of neighbours for certain types of entities. [...]

belt_neighbours :: R table

The belt connectable neighbours of this belt connectable entity. [...]

The belt connectable neighbours of this belt connectable entity. [...]

fluidbox changed :: R LuaFluidBox

Fluidboxes of this entity.

Fluidboxes of this entity.

backer_name :: RW string?

The backer name assigned to this entity. [...]

The backer name assigned to this entity. [...]

entity_label :: RW string?

The label on this spider-vehicle entity, if any. [...]

The label on this spider-vehicle entity, if any. [...]

time_to_live changed :: RW uint64

The ticks left before a combat robot, highlight box, smoke, or sticker entity is destroyed.

The ticks left before a combat robot, highlight box, smoke, or sticker entity is destroyed.

color :: RW Color?

The color of this character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner. [...]

The color of this character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner. [...]

signal_state :: R defines.signal_state

The state of this rail signal.

The state of this rail signal.

chain_signal_state :: R defines.chain_signal_state

The state of this chain signal.

The state of this chain signal.

to_be_looted :: RW boolean

Will this item entity be picked up automatically when the player walks over it?

Will this item entity be picked up automatically when the player walks over it?

crafting_speed :: R double

The current crafting speed, including speed bonuses from modules and beacons.

The current crafting speed, including speed bonuses from modules and beacons.

crafting_progress :: RW float

The current crafting progress, as a number in range [0, 1].

The current crafting progress, as a number in range [0, 1].

bonus_progress :: RW double

The current productivity bonus progress, as a number in range [0, 1].

The current productivity bonus progress, as a number in range [0, 1].

result_quality new :: R LuaQualityPrototype | W QualityID?

The quality produced when this crafting machine finishes crafting. [...]

The quality produced when this crafting machine finishes crafting. [...]

productivity_bonus :: R double

The productivity bonus of this entity. [...]

The productivity bonus of this entity. [...]

pollution_bonus :: R double

The pollution bonus of this entity.

The pollution bonus of this entity.

speed_bonus :: R double

The speed bonus of this entity. [...]

The speed bonus of this entity. [...]

consumption_bonus :: R double

The consumption bonus of this entity.

The consumption bonus of this entity.

belt_to_ground_type :: R "input" or "output"

Whether this underground belt goes into or out of the ground.

Whether this underground belt goes into or out of the ground.

loader_type :: RW "input" or "output"

Whether this loader gets items from or puts item into a container.

Whether this loader gets items from or puts item into a container.

rocket_parts :: RW uint

Number of rocket parts in the silo.

Number of rocket parts in the silo.

logistic_network :: RW LuaLogisticNetwork

The logistic network this entity is a part of, or nil if this entity is not a part of any logistic network.

The logistic network this entity is a part of, or nil if this entity is not a part of any logistic network.

logistic_cell :: R LuaLogisticCell

The logistic cell this entity is a part of. [...]

The logistic cell this entity is a part of. [...]

item_requests changed :: R array[ItemCountWithQuality]

Items this ghost will request when revived or items this item request proxy is requesting.

Items this ghost will request when revived or items this item request proxy is requesting.

insert_plan new :: RW array[BlueprintInsertPlan]

The insert plan for this ghost or item request proxy.

The insert plan for this ghost or item request proxy.

removal_plan new :: RW array[BlueprintInsertPlan]

The removal plan for this item request proxy.

The removal plan for this item request proxy.

player :: R LuaPlayer?

The player connected to this character, if any.

The player connected to this character, if any.

damage_dealt :: RW double

The damage dealt by this turret, artillery turret, or artillery wagon.

The damage dealt by this turret, artillery turret, or artillery wagon.

kills :: RW uint

The number of units killed by this turret, artillery turret, or artillery wagon.

The number of units killed by this turret, artillery turret, or artillery wagon.

ignore_unprioritised_targets new :: RW boolean

Whether this turret shoots at targets that are not on its priority list.

Whether this turret shoots at targets that are not on its priority list.

last_user :: RW LuaPlayer or PlayerIdentification?

The last player that changed any setting on this entity. [...]

The last player that changed any setting on this entity. [...]

electric_buffer_size :: RW double?

The buffer size for the electric energy source. [...]

The buffer size for the electric energy source. [...]

electric_drain :: R double?

The electric drain for the electric energy source. [...]

The electric drain for the electric energy source. [...]

electric_emissions_per_joule new :: R dictionary[string → double] ?

The table of emissions of this energy source in pollution/Joule, indexed by pollutant type. [...]

The table of emissions of this energy source in pollution/Joule, indexed by pollutant type. [...]

unit_number :: R uint?

A unique number identifying this entity for the lifetime of the save. [...]

A unique number identifying this entity for the lifetime of the save. [...]

ghost_unit_number :: R uint?

The unit_number of the entity contained in this ghost. [...]

The unit_number of the entity contained in this ghost. [...]

mining_progress :: RW double?

The mining progress for this mining drill. [...]

The mining progress for this mining drill. [...]

bonus_mining_progress :: RW double?

The bonus mining progress for this mining drill. [...]

The bonus mining progress for this mining drill. [...]

power_production :: RW double

The power production specific to the ElectricEnergyInterface entity type.

The power production specific to the ElectricEnergyInterface entity type.

power_usage :: RW double

The power usage specific to the ElectricEnergyInterface entity type.

The power usage specific to the ElectricEnergyInterface entity type.

bounding_box :: R BoundingBox

LuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation.

LuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation.

secondary_bounding_box :: R BoundingBox?

The secondary bounding box of this entity or nil if it doesn't have one. [...]

The secondary bounding box of this entity or nil if it doesn't have one. [...]

selection_box :: R BoundingBox

LuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation.

LuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation.

secondary_selection_box :: R BoundingBox?

The secondary selection box of this entity or nil if it doesn't have one. [...]

The secondary selection box of this entity or nil if it doesn't have one. [...]

mining_target :: R LuaEntity?

The mining target, if any.

The mining target, if any.

filter_slot_count :: R uint

The number of filter slots this inserter, loader, mining drill or logistic storage container has. [...]

The number of filter slots this inserter, loader, mining drill or logistic storage container has. [...]

loader_container :: R LuaEntity?

The container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type, if any.

The container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type, if any.

grid :: R LuaEquipmentGrid?

This entity's equipment grid, if any.

This entity's equipment grid, if any.

graphics_variation :: RW uint8?

The graphics variation for this entity. [...]

The graphics variation for this entity. [...]

tree_color_index :: RW uint8

Index of the tree color.

Index of the tree color.

tree_color_index_max :: R uint8

Maximum index of the tree colors.

Maximum index of the tree colors.

tree_stage_index :: RW uint8

Index of the tree stage.

Index of the tree stage.

tree_stage_index_max :: R uint8

Maximum index of the tree stages.

Maximum index of the tree stages.

tree_gray_stage_index :: RW uint8

Index of the tree gray stage

Index of the tree gray stage

tree_gray_stage_index_max :: R uint8

Maximum index of the tree gray stages.

Maximum index of the tree gray stages.

burner :: R LuaBurner?

The burner energy source for this entity, if any.

The burner energy source for this entity, if any.

shooting_target :: RW LuaEntity?

The shooting target for this turret, if any. [...]

The shooting target for this turret, if any. [...]

proxy_target :: R LuaEntity?

The target entity for this item-request-proxy, if any.

The target entity for this item-request-proxy, if any.

stickers :: R array[LuaEntity] ?

The sticker entities attached to this entity, if any.

The sticker entities attached to this entity, if any.

sticked_to :: R LuaEntity

The entity this sticker is sticked to.

The entity this sticker is sticked to.

sticker_vehicle_modifiers changed :: R table ?

The vehicle modifiers applied to this entity through the attached stickers.

The vehicle modifiers applied to this entity through the attached stickers.

parameters :: RW ProgrammableSpeakerParameters
alert_parameters :: RW ProgrammableSpeakerAlertParameters
electric_network_statistics :: R LuaFlowStatistics

The electric network statistics for this electric pole.

The electric network statistics for this electric pole.

inserter_target_pickup_count :: R uint

Returns the current target pickup count of the inserter. [...]

Returns the current target pickup count of the inserter. [...]

inserter_stack_size_override :: RW uint

Sets the stack size limit on this inserter. [...]

Sets the stack size limit on this inserter. [...]

products_finished :: RW uint

The number of products this machine finished crafting in its lifetime.

The number of products this machine finished crafting in its lifetime.

spawning_cooldown :: R double
absorbed_pollution :: R double
spawn_shift :: R double
units :: R array[LuaEntity]

The units associated with this spawner entity.

The units associated with this spawner entity.

power_switch_state :: RW boolean

The state of this power switch.

The state of this power switch.

combinator_description new :: RW string

The description on this combinator

The description on this combinator

effects :: R ModuleEffects?

The effects being applied to this entity, if any. [...]

The effects being applied to this entity, if any. [...]

beacons_count :: R uint?

Number of beacons affecting this effect receiver. [...]

Number of beacons affecting this effect receiver. [...]

infinity_container_filters :: RW array[InfinityInventoryFilter]

The filters for this infinity container.

The filters for this infinity container.

remove_unfiltered_items :: RW boolean

Whether items not included in this infinity container filters should be removed from the container.

Whether items not included in this infinity container filters should be removed from the container.

character_corpse_player_index :: RW uint

The player index associated with this character corpse. [...]

The player index associated with this character corpse. [...]

character_corpse_tick_of_death :: RW uint

The tick this character corpse died at.

The tick this character corpse died at.

character_corpse_death_cause :: RW LocalisedString

The reason this character corpse character died. [...]

The reason this character corpse character died. [...]

associated_player :: RW LuaPlayer or PlayerIdentification?

The player this character is associated with, if any. [...]

The player this character is associated with, if any. [...]

tick_of_last_attack :: RW uint

The last tick this character entity was attacked.

The last tick this character entity was attacked.

tick_of_last_damage :: RW uint

The last tick this character entity was damaged.

The last tick this character entity was damaged.

splitter_filter changed :: RW ItemFilter?

The filter for this splitter, if any is set.

The filter for this splitter, if any is set.

inserter_filter_mode :: RW "whitelist" or "blacklist"?

The filter mode for this filter inserter. [...]

The filter mode for this filter inserter. [...]

loader_filter_mode new :: RW "none" or "whitelist" or "blacklist"?

The filter mode for this loader. [...]

The filter mode for this loader. [...]

mining_drill_filter_mode new :: RW "whitelist" or "blacklist"?

The filter mode for this mining drill. [...]

The filter mode for this mining drill. [...]

splitter_input_priority :: RW "left" or "none" or "right"

The input priority for this splitter.

The input priority for this splitter.

splitter_output_priority :: RW "left" or "none" or "right"

The output priority for this splitter.

The output priority for this splitter.

armed :: R boolean

Whether this land mine is armed.

Whether this land mine is armed.

recipe_locked :: RW boolean

When locked; the recipe in this assembling machine can't be changed by the player.

When locked; the recipe in this assembling machine can't be changed by the player.

connected_rail :: R LuaEntity?

The rail entity this train stop is connected to, if any.

The rail entity this train stop is connected to, if any.

connected_rail_direction :: R defines.rail_direction

Rail direction to which this train stop is binding. [...]

Rail direction to which this train stop is binding. [...]

trains_in_block :: R uint

The number of trains in this rail block for this rail entity.

The number of trains in this rail block for this rail entity.

timeout :: RW uint

The timeout that's left on this landmine in ticks. [...]

The timeout that's left on this landmine in ticks. [...]

neighbour_bonus :: R double

The current total neighbour bonus of this reactor.

The current total neighbour bonus of this reactor.

ai_settings :: R LuaAISettings

The ai settings of this unit.

The ai settings of this unit.

highlight_box_type :: RW CursorBoxRenderType

The highlight box type of this highlight box entity.

The highlight box type of this highlight box entity.

highlight_box_blink_interval :: RW uint

The blink interval of this highlight box entity. [...]

The blink interval of this highlight box entity. [...]

status :: R defines.entity_status?

The status of this entity, if any. [...]

The status of this entity, if any. [...]

custom_status new :: RW CustomEntityStatus?

A custom status for this entity that will be displayed in the GUI.

A custom status for this entity that will be displayed in the GUI.

enable_logistics_while_moving :: RW boolean

Whether equipment grid logistics are enabled while this vehicle is moving.

Whether equipment grid logistics are enabled while this vehicle is moving.

render_player :: RW LuaPlayer or PlayerIdentification?

The player that this simple-entity-with-owner, simple-entity-with-force, or highlight-box is visible to. [...]

The player that this simple-entity-with-owner, simple-entity-with-force, or highlight-box is visible to. [...]

render_to_forces changed :: RW ForceSet?

The forces that this simple-entity-with-owner or simple-entity-with-force is visible to. [...]

The forces that this simple-entity-with-owner or simple-entity-with-force is visible to. [...]

pump_rail_target :: R LuaEntity?

The rail target of this pump, if any.

The rail target of this pump, if any.

electric_network_id :: R uint?

Returns the id of the electric network that this entity is connected to, if any.

Returns the id of the electric network that this entity is connected to, if any.

allow_dispatching_robots :: RW boolean

Whether this character's personal roboports are allowed to dispatch robots.

Whether this character's personal roboports are allowed to dispatch robots.

energy_generated_last_tick :: R double

How much energy this generator generated in the last tick.

How much energy this generator generated in the last tick.

storage_filter :: RW LuaItemPrototype?

The storage filter for this logistic storage container. [...]

The storage filter for this logistic storage container. [...]

request_from_buffers :: RW boolean

Whether this requester chest is set to also request from buffer chests. [...]

Whether this requester chest is set to also request from buffer chests. [...]

corpse_expires :: RW boolean

Whether this corpse will ever fade away.

Whether this corpse will ever fade away.

corpse_immune_to_entity_placement :: RW boolean

If true, corpse won't be destroyed when entities are placed over it. [...]

If true, corpse won't be destroyed when entities are placed over it. [...]

tags :: RW Tags?

The tags associated with this entity ghost. [...]

The tags associated with this entity ghost. [...]

time_to_next_effect :: RW uint

The ticks until the next trigger effect of this smoke-with-trigger.

The ticks until the next trigger effect of this smoke-with-trigger.

autopilot_destination :: RW MapPosition?

Destination of this spidertron's autopilot, if any. [...]

Destination of this spidertron's autopilot, if any. [...]

autopilot_destinations :: R array[MapPosition]

The queued destination positions of spidertron's autopilot.

The queued destination positions of spidertron's autopilot.

trains_count :: R uint

Amount of trains related to this particular train stop. [...]

Amount of trains related to this particular train stop. [...]

trains_limit :: RW uint

Amount of trains above which no new trains will be sent to this train stop. [...]

Amount of trains above which no new trains will be sent to this train stop. [...]

is_military_target :: RW boolean

Whether this entity is a MilitaryTarget. [...]

Whether this entity is a MilitaryTarget. [...]

is_entity_with_owner :: R boolean

If this entity is EntityWithOwner

If this entity is EntityWithOwner

is_entity_with_health :: R boolean

If this entity is EntityWithHealth

If this entity is EntityWithHealth

combat_robot_owner :: RW LuaEntity?

The owner of this combat robot, if any.

The owner of this combat robot, if any.

link_id :: RW uint

The link ID this linked container is using.

The link ID this linked container is using.

follow_target :: RW LuaEntity?

The follow target of this spidertron, if any.

The follow target of this spidertron, if any.

follow_offset :: RW Vector?

The follow offset of this spidertron, if any entity is being followed. [...]

The follow offset of this spidertron, if any entity is being followed. [...]

linked_belt_type :: RW "input" or "output"

Type of linked belt. [...]

Type of linked belt. [...]

linked_belt_neighbour :: R LuaEntity?

Neighbour to which this linked belt is connected to, if any. [...]

Neighbour to which this linked belt is connected to, if any. [...]

quality new :: R LuaQualityPrototype

The quality of this entity. [...]

The quality of this entity. [...]

rail_layer new :: R defines.rail_layer

Gets rail layer of a given signal

Gets rail layer of a given signal

radar_scan_progress :: R float

The current radar scan progress, as a number in range [0, 1].

The current radar scan progress, as a number in range [0, 1].

name_tag new :: RW string

Name tag of this entity. [...]

Name tag of this entity. [...]

rocket_silo_status :: R defines.rocket_silo_status

The status of this rocket silo entity.

The status of this rocket silo entity.

tile_width :: R uint

Specifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). [...]

Specifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). [...]

tile_height :: R uint

Specifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). [...]

Specifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). [...]

crane_destination new :: RW MapPosition

Destination of the crane of this entity. [...]

Destination of the crane of this entity. [...]

crane_destination_3d new :: RW Vector3D

Destination of the crane of this entity in 3D. [...]

Destination of the crane of this entity in 3D. [...]

crane_grappler_destination new :: W MapPosition

Will set destination for the grappler of crane of this entity. [...]

Will set destination for the grappler of crane of this entity. [...]

crane_grappler_destination_3d new :: W Vector3D

Will set destination in 3D for the grappler of crane of this entity. [...]

Will set destination in 3D for the grappler of crane of this entity. [...]

copy_color_from_train_stop new :: RW boolean

If this RollingStock has 'copy color from train stop' enabled.

If this RollingStock has 'copy color from train stop' enabled.

is_headed_to_trains_front :: R boolean

If the rolling stock is facing train's front.

If the rolling stock is facing train's front.

draw_data :: R RollingStockDrawData

Gives a draw data of the given entity if it supports such data.

Gives a draw data of the given entity if it supports such data.

train_stop_priority new :: RW uint8

Priority of this train stop.

Priority of this train stop.

belt_shape :: R "straight" or "left" or "right"

Gives what is the current shape of a transport-belt. [...]

Gives what is the current shape of a transport-belt. [...]

gps_tag :: R string

Returns a rich text string containing this entity's position and surface name as a gps tag. [...]

Returns a rich text string containing this entity's position and surface name as a gps tag. [...]

commandable new :: R LuaCommandable?

Returns a LuaCommandable for this entity or nil if entity is not commandable.

Returns a LuaCommandable for this entity or nil if entity is not commandable.

fluids_count new :: R uint

Returns count of fluid storages. [...]

Returns count of fluid storages. [...]

tick_grown new :: RW MapTick

The tick when this plant is fully grown.

The tick when this plant is fully grown.

always_on new :: RW boolean

If the lamp is always on when not driven by control behavior.

If the lamp is always on when not driven by control behavior.

artillery_auto_targeting new :: RW boolean

If this artillery auto-targets enemies.

If this artillery auto-targets enemies.

robot_order_queue new :: R array[WorkerRobotOrder]

Get the current queue of robot orders.

Get the current queue of robot orders.

cargo_pod new :: R LuaEntity?

Gets the cargo pod attached to this rocket silo rocket if one exists.

Gets the cargo pod attached to this rocket silo rocket if one exists.

procession_tick new :: RW MapTick

how far into the current procession the cargo pod is.

how far into the current procession the cargo pod is.

valid :: R boolean

Is this object valid? [...]

Is this object valid? [...]

object_name :: R string

The class name of this object. [...]

The class name of this object. [...]

Inherited from LuaControl
get_inventory(inventory) LuaInventory?

Get an inventory belonging to this entity. [...]

Get an inventory belonging to this entity. [...]

get_max_inventory_index() defines.inventory

The highest index of all inventories this entity can use. [...]

The highest index of all inventories this entity can use. [...]

get_main_inventory() LuaInventory?

Gets the main inventory for this character or player if this is a character or player.

Gets the main inventory for this character or player if this is a character or player.

can_insert(items) boolean

Can at least some items be inserted?

Can at least some items be inserted?

insert(items) uint

Insert items into this entity. [...]

Insert items into this entity. [...]

set_gui_arrow{margin=…, type=…}

Create an arrow which points at this entity. [...]

Create an arrow which points at this entity. [...]

clear_gui_arrow()

Removes the arrow created by set_gui_arrow.

Removes the arrow created by set_gui_arrow.

get_item_count(item?) changeduint

Get the number of all or some items in this entity.

Get the number of all or some items in this entity.

has_items_inside() boolean

Does this entity have any item inside it?

Does this entity have any item inside it?

can_reach_entity(entity) boolean

Can a given entity be opened or accessed?

Can a given entity be opened or accessed?

clear_items_inside()

Remove all items from this entity.

Remove all items from this entity.

remove_item(items) uint

Remove items from this entity.

Remove items from this entity.

teleport(position, surface?, raise_teleported?, snap_to_grid?) changedboolean

Teleport the entity to a given position, possibly on another surface. [...]

Teleport the entity to a given position, possibly on another surface. [...]

update_selected_entity(position)

Select an entity, as if by hovering the mouse above it.

Select an entity, as if by hovering the mouse above it.

clear_selected_entity()

Unselect any selected entity.

Unselect any selected entity.

disable_flashlight()

Disable the flashlight.

Disable the flashlight.

enable_flashlight()

Enable the flashlight.

Enable the flashlight.

is_flashlight_enabled() boolean

Is the flashlight enabled.

Is the flashlight enabled.

get_craftable_count(recipe) changeduint

Gets the count of the given recipe that can be crafted.

Gets the count of the given recipe that can be crafted.

begin_crafting{count=…, recipe=…, silent?=…} changeduint

Begins crafting the given count of the given recipe.

Begins crafting the given count of the given recipe.

cancel_crafting{index=…, count=…}

Cancels crafting the given count of the given crafting queue index.

Cancels crafting the given count of the given crafting queue index.

mine_entity(entity, force?) boolean

Mines the given entity as if this player (or character) mined it.

Mines the given entity as if this player (or character) mined it.

mine_tile(tile) boolean

Mines the given tile as if this player (or character) mined it.

Mines the given tile as if this player (or character) mined it.

is_player() boolean

When true control adapter is a LuaPlayer object, false for entities including characters with players.

When true control adapter is a LuaPlayer object, false for entities including characters with players.

open_technology_gui(technology?) changed

Open the technology GUI and select a given technology.

Open the technology GUI and select a given technology.

is_cursor_blueprint() boolean

Returns whether the player is holding a blueprint. [...]

Returns whether the player is holding a blueprint. [...]

is_cursor_empty() boolean

Returns whether the player is holding something in the cursor. [...]

Returns whether the player is holding something in the cursor. [...]

get_requester_point() newLuaLogisticPoint?

Gets the requester logistic point for this entity if it has one.

Gets the requester logistic point for this entity if it has one.

set_driving(driving, force?) new

Sets if this characer or player is driving. [...]

Sets if this characer or player is driving. [...]

surface :: R LuaSurface

The surface this entity is currently on.

The surface this entity is currently on.

surface_index :: R uint

Unique index (ID) associated with the surface this entity is currently on.

Unique index (ID) associated with the surface this entity is currently on.

position :: R MapPosition

The current position of the entity.

The current position of the entity.

vehicle :: R LuaEntity?

The vehicle the player is currently sitting in.

The vehicle the player is currently sitting in.

force changed :: R LuaForce | W ForceID

The force of this entity. [...]

The force of this entity. [...]

force_index :: R uint

Unique index (ID) associated with the force of this entity.

Unique index (ID) associated with the force of this entity.

selected :: RW LuaEntity?

The currently selected entity. [...]

The currently selected entity. [...]

opened changed :: RW LuaEntity or LuaItemStack or LuaEquipment or LuaEquipmentGrid or LuaPlayer or LuaGuiElement or LuaInventory or LuaLogisticNetwork or defines.gui_type?

The GUI the player currently has open. [...]

The GUI the player currently has open. [...]

crafting_queue_size :: R uint

Size of the crafting queue.

Size of the crafting queue.

crafting_queue_progress :: RW double

The crafting queue progress in the range [0-1]. [...]

The crafting queue progress in the range [0-1]. [...]

walking_state :: RW table

Current walking state.

Current walking state.

riding_state :: RW RidingState

Current riding state of this car, or of the car this player is riding in.

Current riding state of this car, or of the car this player is riding in.

mining_state :: RW table

Current mining state. [...]

Current mining state. [...]

shooting_state :: RW table

Current shooting state.

Current shooting state.

picking_state :: RW boolean

Current item-picking state.

Current item-picking state.

repair_state :: RW table

Current repair state.

Current repair state.

cursor_stack :: R LuaItemStack?

The player's cursor stack. [...]

The player's cursor stack. [...]

cursor_ghost changed :: R ItemIDAndQualityIDPair | W ItemWithQualityID?

The ghost prototype in the player's cursor. [...]

The ghost prototype in the player's cursor. [...]

cursor_record new :: R LuaRecord?

The blueprint record in the player's cursor.

The blueprint record in the player's cursor.

driving :: RW boolean

true if the player is in a vehicle. [...]

true if the player is in a vehicle. [...]

crafting_queue :: R array[CraftingQueueItem]

The current crafting queue items.

The current crafting queue items.

following_robots :: R array[LuaEntity]

The current combat robots following the character. [...]

The current combat robots following the character. [...]

cheat_mode :: RW boolean

When true hand crafting is free and instant.

When true hand crafting is free and instant.

character_crafting_speed_modifier :: RW double

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_mining_speed_modifier :: RW double

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_additional_mining_categories :: RW array[string]

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_running_speed_modifier :: RW double

Modifies the running speed of this character by the given value as a percentage. [...]

Modifies the running speed of this character by the given value as a percentage. [...]

character_build_distance_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_item_drop_distance_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_reach_distance_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_resource_reach_distance_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_item_pickup_distance_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_loot_pickup_distance_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_inventory_slots_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_trash_slot_count_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_maximum_following_robot_count_bonus :: RW uint

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

character_health_bonus :: RW float

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

opened_gui_type :: R defines.gui_type?
build_distance :: R uint

The build distance of this character or max uint when not a character or player connected to a character.

The build distance of this character or max uint when not a character or player connected to a character.

drop_item_distance :: R uint

The item drop distance of this character or max uint when not a character or player connected to a character.

The item drop distance of this character or max uint when not a character or player connected to a character.

reach_distance :: R uint

The reach distance of this character or max uint when not a character or player connected to a character.

The reach distance of this character or max uint when not a character or player connected to a character.

item_pickup_distance :: R double

The item pickup distance of this character or max double when not a character or player connected to a character.

The item pickup distance of this character or max double when not a character or player connected to a character.

loot_pickup_distance :: R double

The loot pickup distance of this character or max double when not a character or player connected to a character.

The loot pickup distance of this character or max double when not a character or player connected to a character.

resource_reach_distance :: R double

The resource reach distance of this character or max double when not a character or player connected to a character.

The resource reach distance of this character or max double when not a character or player connected to a character.

in_combat :: R boolean

Whether this character entity is in combat.

Whether this character entity is in combat.

character_running_speed :: R double

The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.

The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.

character_mining_progress :: R double

The current mining progress between 0 and 1 of this character, or 0 if they aren't mining.

The current mining progress between 0 and 1 of this character, or 0 if they aren't mining.

Methods

get_output_inventory() → LuaInventory?

Gets the entity's output inventory if it has one.

Return values

→ LuaInventory?

A reference to the entity's output inventory.


get_module_inventory() → LuaInventory?

Inventory for storing modules of this entity; nil if this entity has no module inventory.


get_fuel_inventory() → LuaInventory?

The fuel inventory for this entity or nil if this entity doesn't have a fuel inventory.


get_burnt_result_inventory() → LuaInventory?

The burnt result inventory for this entity or nil if this entity doesn't have a burnt result inventory.


damage(damage, force, type?, source?, cause?) → floatchanged

Damages the entity.

Parameters

damage :: float

The amount of damage to be done.

The amount of damage to be done.

force :: ForceID

The force that will be doing the damage.

The force that will be doing the damage.

type :: DamageTypeID?

The type of damage to be done, defaults to "impact".

The type of damage to be done, defaults to "impact".

source :: LuaEntity?

The entity that is directly dealing the damage (e.g. the projectile, flame, sticker, grenade, laser beam, etc.). Needs to be on the same surface as the entity being damaged.

The entity that is directly dealing the damage (e.g. the projectile, flame, sticker, grenade, laser beam, etc.). Needs to be on the same surface as the entity being damaged.

cause :: LuaEntity?

The entity that originally triggered the events that led to this damage being dealt (e.g. the character, turret, enemy, etc. that pulled the trigger). Does not need to be on the same surface as the entity being damaged.

The entity that originally triggered the events that led to this damage being dealt (e.g. the character, turret, enemy, etc. that pulled the trigger). Does not need to be on the same surface as the entity being damaged.

Return values

→ float

the total damage actually applied after resistances.

Raised events

Can only be used if this is EntityWithHealth

can_be_destroyed() → boolean

Whether the entity can be destroyed


destroy{do_cliff_correction?=…, raise_destroy?=…, player?=…, item_index?=…} → booleanchanged

Destroys the entity.

Not all entities can be destroyed - things such as rails under trains cannot be destroyed until the train is moved or destroyed.

Parameters

Table (optional) with the following fields:
do_cliff_correction :: boolean?

Whether neighbouring cliffs should be corrected. Defaults to false.

Whether neighbouring cliffs should be corrected. Defaults to false.

raise_destroy :: boolean?

If true, script_raised_destroy will be called. Defaults to false.

If true, script_raised_destroy will be called. Defaults to false.

player :: PlayerIdentification?

The player whose undo queue this action should be added to.

The player whose undo queue this action should be added to.

item_index :: uint?

The index of the undo item to add this action to. An index of 0 creates a new undo item for it. Defaults to putting it into the appropriate undo item automatically if not specified.

The index of the undo item to add this action to. An index of 0 creates a new undo item for it. Defaults to putting it into the appropriate undo item automatically if not specified.

Return values

→ boolean

Returns false if the entity was valid and destruction failed, true in all other cases.

Raised events

script_raised_destroy? instantly

Raised if the raise_destroy flag was set and the entity was successfully destroyed.


die(force?, cause?) → booleanchanged

Immediately kills the entity. Does nothing if the entity doesn't have health.

Unlike LuaEntity::destroy, die will trigger the on_entity_died event and the entity will produce a corpse and drop loot if it has any.

Parameters

force :: ForceID?

The force to attribute the kill to.

The force to attribute the kill to.

cause :: LuaEntity?

The cause to attribute the kill to.

The cause to attribute the kill to.

Return values

→ boolean

Whether the entity was successfully killed.

Raised events

on_entity_died? instantly

Raised if the entity was successfully killed. If force is not specified, the event will blame the "neutral" force.

on_post_entity_died? instantly

Raised if the entity was successfully killed.

Example

-- This function can be called with only the `cause` argument and no `force`:
entity.die(nil, killer_entity)

has_flag(flag) → boolean

Test whether this entity's prototype has a certain flag set.

entity.has_flag(f) is a shortcut for entity.prototype.has_flag(f).

Parameters

flag :: EntityPrototypeFlag

The flag to test.

The flag to test.

Return values

→ boolean

true if this entity has the given flag set.


ghost_has_flag(flag) → boolean

Same as LuaEntity::has_flag, but targets the inner entity on a entity ghost.

Parameters

flag :: EntityPrototypeFlag

The flag to test.

The flag to test.

Return values

→ boolean

true if the entity has the given flag set.

Can only be used if this is EntityGhost

add_market_item(offer)

Offer a thing on the market.

Parameters

offer :: Offer

Can only be used if this is Market

Examples

-- Adds market offer, 1 copper ore for 10 iron ore
market.add_market_item{price={{name = "iron-ore", count = 10}}, offer={type="give-item", item="copper-ore"}}
-- Adds market offer, 1 copper ore for 5 iron ore and 5 stone ore
market.add_market_item{price={{name = "iron-ore", count = 5}, {name = "stone", count = 5}}, offer={type="give-item", item="copper-ore"}}

remove_market_item(offer) → boolean

Remove an offer from a market.

The other offers are moved down to fill the gap created by removing the offer, which decrements the overall size of the offer array.

Parameters

offer :: uint

Index of offer to remove.

Index of offer to remove.

Return values

→ boolean

true if the offer was successfully removed; false when the given index was not valid.

Can only be used if this is Market

get_market_items() → array[Offer]

Get all offers in a market as an array.

Can only be used if this is Market

clear_market_items()

Removes all offers from a market.

Can only be used if this is Market

order_deconstruction(force, player?, item_index?) → booleanchanged

Sets the entity to be deconstructed by construction robots.

Parameters

force :: ForceID

The force whose robots are supposed to do the deconstruction.

The force whose robots are supposed to do the deconstruction.

player :: PlayerIdentification?

The player to set the last_user to, if any. Also the player whose undo queue this action should be added to.

The player to set the last_user to, if any. Also the player whose undo queue this action should be added to.

item_index :: uint?

The index of the undo item to add this action to. An index of 0 creates a new undo item for it. An index of 1 adds the action to the latest undo action on the stack. Defaults to putting it into the appropriate undo item automatically if one is not specified.

The index of the undo item to add this action to. An index of 0 creates a new undo item for it. An index of 1 adds the action to the latest undo action on the stack. Defaults to putting it into the appropriate undo item automatically if one is not specified.

Return values

→ boolean

if the entity was marked for deconstruction.

Raised events

on_marked_for_deconstruction? instantly

Raised if the entity was successfully marked for deconstruction.


cancel_deconstruction(force, player?) changed

Cancels deconstruction if it is scheduled, does nothing otherwise.

Parameters

force :: ForceID

The force who did the deconstruction order.

The force who did the deconstruction order.

player :: PlayerIdentification?

The player to set the last_user to if any.

The player to set the last_user to if any.

Raised events

on_cancelled_deconstruction? instantly

Raised if the entity's deconstruction was successfully cancelled.


to_be_deconstructed() → boolean

Is this entity marked for deconstruction?


order_upgrade{target=…, force=…, player?=…, item_index?=…} → booleanchanged

Sets the entity to be upgraded by construction robots.

Parameters

Table with the following fields:
target :: EntityWithQualityID

The prototype of the entity to upgrade to.

The prototype of the entity to upgrade to.

force :: ForceID

The force whose robots are supposed to do the upgrade.

The force whose robots are supposed to do the upgrade.

player :: PlayerIdentification?

The player whose undo queue this action should be added to.

The player whose undo queue this action should be added to.

item_index :: uint?

The index of the undo item to add this action to. An index of 0 creates a new undo item for it. Defaults to putting it into the appropriate undo item automatically if not specified.

The index of the undo item to add this action to. An index of 0 creates a new undo item for it. Defaults to putting it into the appropriate undo item automatically if not specified.

Return values

→ boolean

Whether the entity was marked for upgrade.

Raised events

on_marked_for_upgrade? instantly

Raised if the entity was successfully marked for upgrade.


cancel_upgrade(force, player?) → booleanchanged

Cancels upgrade if it is scheduled, does nothing otherwise.

Parameters

force :: ForceID

The force who did the upgrade order.

The force who did the upgrade order.

player :: PlayerIdentification?

The player to set the last_user to if any.

The player to set the last_user to if any.

Return values

→ boolean

Whether the cancel was successful.

Raised events

on_cancelled_upgrade? instantly

Raised if the entity way previously marked for upgrade.


to_be_upgraded() → boolean

Is this entity marked for upgrade?


is_crafting() → boolean

Returns whether a craft is currently in process. It does not indicate whether progress is currently being made, but whether a crafting process has been started in this machine.

Can only be used if this is CraftingMachine

is_opened() → boolean

Return values

→ boolean

true if this gate is currently opened.

Can only be used if this is Gate

is_opening() → boolean

Return values

→ boolean

true if this gate is currently opening.

Can only be used if this is Gate

is_closed() → boolean

Return values

→ boolean

true if this gate is currently closed.

Can only be used if this is Gate

is_closing() → boolean

Return values

→ boolean

true if this gate is currently closing

Can only be used if this is Gate

request_to_open(force, extra_time?) changed

Parameters

force :: ForceID

The force that requests the gate to be open.

The force that requests the gate to be open.

extra_time :: uint?

Extra ticks to stay open.

Extra ticks to stay open.

Can only be used if this is Gate

request_to_close(force) changed

Parameters

force :: ForceID

The force that requests the gate to be closed.

The force that requests the gate to be closed.

Can only be used if this is Gate

get_transport_line(index) → LuaTransportLine

Get a transport line of a belt or belt connectable entity.

Parameters

index :: uint

Index of the requested transport line. Transport lines are 1-indexed.

Index of the requested transport line. Transport lines are 1-indexed.

Can only be used if this is TransportBeltConnectable

get_item_insert_specification(position) → uint, floatnew

Get an item insert specification onto a belt connectable: for a given map position provides into which line at what position item should be inserted to be closest to the provided position.

Parameters

position :: MapPosition

Position where the item is to be inserted.

Position where the item is to be inserted.

Return values

→ uint

Index of the transport line that is closest to the provided map position.

→ float

Position along the transport line where item should be dropped.

Can only be used if this is TransportBeltConnectable

get_line_item_position(index, position) → MapPositionnew

Get a map position related to a position on a transport line.

Parameters

index :: uint

Index of the transport line. Transport lines are 1-indexed.

Index of the transport line. Transport lines are 1-indexed.

position :: float

Linear position along the transport line. Clamped to the transport line range.

Linear position along the transport line. Clamped to the transport line range.

Can only be used if this is TransportBeltConnectable

get_max_transport_line_index() → uint

Get the maximum transport line index of a belt or belt connectable entity.

Can only be used if this is TransportBeltConnectable

launch_rocket() → boolean

Return values

→ boolean

true if the rocket was successfully launched. Return value of false means the silo is not ready for launch.

Raised events

on_rocket_launch_ordered? instantly

Raised if the rocket launch was successfully initiated.

Can only be used if this is RocketSilo

revive{return_item_request_proxy?=…, raise_revive?=…} → dictionary[string → uint]?, LuaEntity?, LuaEntity?

Revive a ghost, which turns it from a ghost into a real entity or tile.

Parameters

Table (optional) with the following fields:
return_item_request_proxy :: boolean?

If true the function will return item request proxy as the third return value.

If true the function will return item request proxy as the third return value.

raise_revive :: boolean?

If true, and an entity ghost; script_raised_revive will be called. Else if true, and a tile ghost; script_raised_set_tiles will be called.

If true, and an entity ghost; script_raised_revive will be called. Else if true, and a tile ghost; script_raised_set_tiles will be called.

Return values

→ dictionary[string → uint]?

Any items the new real entity collided with or nil if the ghost could not be revived.

→ LuaEntity?

The revived entity if an entity ghost was successfully revived.

→ LuaEntity?

The item request proxy if it was requested with return_item_request_proxy.

Raised events

script_raised_revive? instantly

Raised if this was an entity ghost and the raise_revive flag was set and the entity was successfully revived.

script_raised_set_tiles? instantly

Raised if this was a tile ghost and the raise_revive flag was set and the tile was successfully revived.

Can only be used if this is Ghost

silent_revive{raise_revive?=…} → array[ItemCountWithQuality], LuaEntity?, LuaEntity?changed

Revives a ghost silently, so the revival makes no sound and no smoke is created.

Parameters

Table (optional) with the following fields:
raise_revive :: boolean?

If true, and an entity ghost; script_raised_revive will be called. Else if true, and a tile ghost; script_raised_set_tiles will be called.

If true, and an entity ghost; script_raised_revive will be called. Else if true, and a tile ghost; script_raised_set_tiles will be called.

Return values

→ array[ItemCountWithQuality]

Any items the new real entity collided with or nil if the ghost could not be revived.

→ LuaEntity?

The revived entity if an entity ghost was successfully revived.

→ LuaEntity?

The item request proxy.

Raised events

script_raised_revive? instantly

Raised if this was an entity ghost and the raise_revive flag was set and the entity was successfully revived.

script_raised_set_tiles? instantly

Raised if this was a tile ghost and the raise_revive flag was set and the tile was successfully revived.

Can only be used if this is Ghost

get_connected_rail{rail_direction=…, rail_connection_direction=…} → LuaEntity?, defines.rail_direction?, defines.rail_connection_direction?

Parameters

Table with the following fields:
rail_direction :: defines.rail_direction
rail_connection_direction :: defines.rail_connection_direction

Return values

→ LuaEntity?

Rail connected in the specified manner to this one, nil if unsuccessful.

→ defines.rail_direction?

Rail direction of the returned rail which points to origin rail

→ defines.rail_connection_direction?

Turn to be taken when going back from returned rail to origin rail

Can only be used if this is Rail

get_connected_rails() → array[LuaEntity]

Get the rails that this signal is connected to.

Can only be used if this is RailSignal or RailChainSignal

get_rail_segment_signal(direction, in_else_out) → LuaEntity?new

Get the rail signal at the start/end of the rail segment this rail is in.

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Parameters

direction :: defines.rail_direction

The direction of travel relative to this rail.

The direction of travel relative to this rail.

in_else_out :: boolean

If true, gets the signal at the entrance of the rail segment, otherwise gets the signal at the exit of the rail segment.

If true, gets the signal at the entrance of the rail segment, otherwise gets the signal at the exit of the rail segment.

Return values

→ LuaEntity?

nil if the rail segment doesn't start/end with a signal.

Can only be used if this is Rail

get_rail_segment_stop(direction) → LuaEntity?new

Get train stop at the start/end of the rail segment this rail is in.

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Parameters

direction :: defines.rail_direction

The direction of travel relative to this rail.

The direction of travel relative to this rail.

Return values

→ LuaEntity?

nil if the rail segment doesn't start/end with a train stop.

Can only be used if this is Rail

get_rail_segment_end(direction) → LuaEntity, defines.rail_direction

Get the rail at the end of the rail segment this rail is in.

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Parameters

direction :: defines.rail_direction

Return values

→ LuaEntity

The rail entity.

→ defines.rail_direction

A rail direction pointing out of the rail segment from the end rail.

Can only be used if this is Rail

get_rail_segment_rails(direction) → array[LuaEntity]

Get all rails of a rail segment this rail is in

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Parameters

direction :: defines.rail_direction

Selects end of this rail that points to a rail segment end from which to start returning rails

Selects end of this rail that points to a rail segment end from which to start returning rails

Return values

→ array[LuaEntity]

Rails of this rail segment

Can only be used if this is Rail

get_rail_segment_length() → double

Get the length of the rail segment this rail is in.

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Can only be used if this is Rail

get_rail_segment_overlaps() → array[LuaEntity]

Get a rail from each rail segment that overlaps with this rail's rail segment.

A rail segment is a continuous section of rail with no branches, signals, nor train stops.

Can only be used if this is Rail

is_rail_in_same_rail_segment_as(other_rail) → boolean

Checks if this rail and other rail both belong to the same rail segment.

Parameters

other_rail :: LuaEntity

Can only be used if this is Rail

is_rail_in_same_rail_block_as(other_rail) → boolean

Checks if this rail and other rail both belong to the same rail block.

Parameters

other_rail :: LuaEntity

Can only be used if this is Rail

get_parent_signals() → array[LuaEntity]

Returns all parent signals. Parent signals are always RailChainSignal. Parent signals are those signals that are checking state of this signal to determine their own chain state.

Can only be used if this is RailSignal or RailChainSignal

get_child_signals() → array[LuaEntity]

Returns all child signals. Child signals can be either RailSignal or RailChainSignal. Child signals are signals which are checked by this signal to determine a chain state.

Can only be used if this is RailChainSignal

get_inbound_signals() → array[LuaEntity]

Returns all signals guarding entrance to a rail block this rail belongs to.

Can only be used if this is Rail

get_outbound_signals() → array[LuaEntity]

Returns all signals guarding exit from a rail block this rail belongs to.

Can only be used if this is Rail

get_filter(slot_index) → ItemFilter?changed

Get the filter for a slot in an inserter, loader, or logistic storage container. The entity must allow filters.

Parameters

slot_index :: uint

Index of the slot to get the filter for.

Index of the slot to get the filter for.

Return values

→ ItemFilter?

The filter, or nil if the given slot has no filter.


set_filter(index, filter?) changed

Set the filter for a slot in an inserter (ItemFilter), loader (ItemFilter), mining drill (EntityID) or logistic storage container (ItemWithQualityID). The entity must allow filters.

Parameters

index :: uint

Index of the slot to set the filter for.

Index of the slot to set the filter for.

filter :: ItemFilter or ItemWithQualityID or EntityID?

The item or entity to filter, or nil to clear the filter.

The item or entity to filter, or nil to clear the filter.


get_infinity_container_filter(index) → InfinityInventoryFilter?

Gets the filter for this infinity container at the given index, or nil if the filter index doesn't exist or is empty.

Parameters

index :: uint

The index to get.

The index to get.

Can only be used if this is InfinityContainer

set_infinity_container_filter(index, filter)

Sets the filter for this infinity container at the given index.

Parameters

index :: uint

The index to set.

The index to set.

filter :: InfinityInventoryFilter or nil

The new filter, or nil to clear the filter.

The new filter, or nil to clear the filter.

Can only be used if this is InfinityContainer

get_infinity_pipe_filter() → InfinityPipeFilter?

Gets the filter for this infinity pipe, or nil if the filter is empty.

Can only be used if this is InfinityPipe

set_infinity_pipe_filter(filter)

Sets the filter for this infinity pipe.

Parameters

filter :: InfinityPipeFilter or nil

The new filter, or nil to clear the filter.

The new filter, or nil to clear the filter.

Can only be used if this is InfinityPipe

get_heat_setting() → HeatSetting

Gets the heat setting for this heat interface.

Can only be used if this is HeatInterface

set_heat_setting(filter)

Sets the heat setting for this heat interface.

Parameters

filter :: HeatSetting

The new setting.

The new setting.

Can only be used if this is HeatInterface

get_control_behavior() → LuaControlBehavior?

Gets the control behavior of the entity (if any).

Return values

→ LuaControlBehavior?

The control behavior or nil.


get_or_create_control_behavior() → LuaControlBehavior?

Gets (and or creates if needed) the control behavior of the entity.

Return values

→ LuaControlBehavior?

The control behavior or nil.


get_circuit_network(wire_connector_id) → LuaCircuitNetwork?changed

Parameters

wire_connector_id :: defines.wire_connector_id

Wire connector to get circuit network for.

Wire connector to get circuit network for.

Return values

→ LuaCircuitNetwork?

The circuit network or nil.


get_signal(signal, wire_connector_id, extra_wire_connector_id?) → intnew

Read a single signal from the selected wire connector

Parameters

signal :: SignalID

The signal to read.

The signal to read.

wire_connector_id :: defines.wire_connector_id

Wire connector ID from which to get the signal

Wire connector ID from which to get the signal

extra_wire_connector_id :: defines.wire_connector_id?

Additional wire connector ID. If specified, signal will be added to the result

Additional wire connector ID. If specified, signal will be added to the result

Return values

→ int

The current value of the signal.


get_signals(wire_connector_id, extra_wire_connector_id?) → array[Signal]?new

Read all signals from the selected wire connector.

Parameters

wire_connector_id :: defines.wire_connector_id

Wire connector ID from which to get the signal

Wire connector ID from which to get the signal

extra_wire_connector_id :: defines.wire_connector_id?

Additional wire connector ID. If specified, signals will be added to the result

Additional wire connector ID. If specified, signals will be added to the result

Return values

→ array[Signal]?

Current values of all signals.


supports_backer_name() → boolean

Whether this entity supports a backer name.


copy_settings(entity, by_player?) → array[ItemCountWithQuality] changed

Copies settings from the given entity onto this entity.

Parameters

entity :: LuaEntity
by_player :: PlayerIdentification?

If provided, the copying is done 'as' this player and on_entity_settings_pasted is triggered.

If provided, the copying is done 'as' this player and on_entity_settings_pasted is triggered.

Return values

→ array[ItemCountWithQuality]

Any items removed from this entity as a result of copying the settings.


get_logistic_point(index?) → LuaLogisticPoint or dictionary[defines.logistic_member_index → LuaLogisticPoint]?

Gets all the LuaLogisticPoints that this entity owns. Optionally returns only the point specified by the index parameter.

When index is not given, this will be a single LuaLogisticPoint for most entities. For some (such as the player character), it can be zero or more.

Parameters

index :: defines.logistic_member_index?

If provided, only returns the LuaLogisticPoint specified by this index.

If provided, only returns the LuaLogisticPoint specified by this index.


play_note(instrument, note) → boolean

Plays a note with the given instrument and note.

Parameters

instrument :: uint
note :: uint

Return values

→ boolean

Whether the request is valid. The sound may or may not be played depending on polyphony settings.

Can only be used if this is ProgrammableSpeaker

connect_rolling_stock(direction) → boolean

Connects the rolling stock in the given direction.

Parameters

direction :: defines.rail_direction

Return values

→ boolean

Whether any connection was made

Can only be used if this is RollingStock

disconnect_rolling_stock(direction) → boolean

Tries to disconnect this rolling stock in the given direction.

Parameters

direction :: defines.rail_direction

Return values

→ boolean

If anything was disconnected

Can only be used if this is RollingStock

update_connections()

Reconnect loader, beacon, cliff and mining drill connections to entities that might have been teleported out or in by the script. The game doesn't do this automatically as we don't want to lose performance by checking this in normal games.


get_recipe() → LuaRecipe?, LuaQualityPrototype?changed

Current recipe being assembled by this machine, if any.

Can only be used if this is CraftingMachine

set_recipe(recipe?, quality?) → array[ItemCountWithQuality] changed

Sets the given recipe in this assembly machine.

Parameters

recipe :: RecipeID?

The new recipe. Writing nil clears the recipe, if any.

The new recipe. Writing nil clears the recipe, if any.

quality :: QualityID?

The quality. If not provided normal is used.

The quality. If not provided normal is used.

Return values

→ array[ItemCountWithQuality]

Any items removed from this entity as a result of setting the recipe.

Can only be used if this is AssemblingMachine

rotate{reverse?=…, by_player?=…} → booleanchanged

Rotates this entity as if the player rotated it.

Parameters

Table (optional) with the following fields:
reverse :: boolean?

If true, rotate the entity in the counter-clockwise direction.

If true, rotate the entity in the counter-clockwise direction.

by_player :: PlayerIdentification?

Return values

→ boolean

Whether the rotation was successful.

Raised events

on_player_rotated_entity? instantly

Raised if the by_player argument was given and the rotation was successful.


get_driver() → LuaEntity or LuaPlayer?

Gets the driver of this vehicle if any.

Return values

→ LuaEntity or LuaPlayer?

nil if the vehicle contains no driver. To check if there's a passenger see LuaEntity::get_passenger.

Can only be used if this is Vehicle

set_driver(driver?)

Sets the driver of this vehicle.

This differs from LuaEntity::set_passenger in that the passenger can't drive the vehicle.

Parameters

driver :: LuaEntity or PlayerIdentification?

The new driver. Writing nil ejects the current driver, if any.

The new driver. Writing nil ejects the current driver, if any.

Raised events

Can only be used if this is Vehicle

get_passenger() → LuaEntity or LuaPlayer?

Gets the passenger of this car or spidertron if any.

This differs over LuaEntity::get_driver in that the passenger can't drive the car.

Return values

→ LuaEntity or LuaPlayer?

nil if the vehicle contains no passenger. To check if there's a driver see LuaEntity::get_driver.

Can only be used if this is Car or SpiderVehicle

set_passenger(passenger?)

Sets the passenger of this car or spidertron.

This differs from LuaEntity::get_driver in that the passenger can't drive the car.

Parameters

passenger :: LuaEntity or PlayerIdentification?

The new passenger. Writing nil ejects the current passenger, if any.

The new passenger. Writing nil ejects the current passenger, if any.

Raised events

Can only be used if this is Car or SpiderVehicle

is_connected_to_electric_network() → boolean

Returns true if this entity produces or consumes electricity and is connected to an electric network that has at least one entity that can produce power.


get_train_stop_trains() → array[LuaTrain]

The trains scheduled to stop at this train stop.

Can only be used if this is TrainStop

get_stopped_train() → LuaTrain?

The train currently stopped at this train stop, if any.

Can only be used if this is TrainStop

clone{position=…, surface?=…, force?=…, create_build_effect_smoke?=…} → LuaEntity?changed

Clones this entity.

Parameters

Table with the following fields:
position :: MapPosition

The destination position

The destination position

surface :: LuaSurface?

The destination surface

The destination surface

force :: ForceID?
create_build_effect_smoke :: boolean?

If false, the building effect smoke will not be shown around the new entity.

If false, the building effect smoke will not be shown around the new entity.

Return values

→ LuaEntity?

The cloned entity or nil if this entity can't be cloned/can't be cloned to the given location.

Raised events

on_entity_cloned? instantly

Raised if the entity was successfully cloned.


get_fluid_count(fluid?) → double

Get the amount of all or some fluid in this entity.

If information about fluid temperatures is required, LuaEntity::fluidbox should be used instead.

Parameters

fluid :: string?

Prototype name of the fluid to count. If not specified, count all fluids.

Prototype name of the fluid to count. If not specified, count all fluids.


get_fluid_contents() → dictionary[string → double]

Get amounts of all fluids in this entity.

If information about fluid temperatures is required, LuaEntity::fluidbox should be used instead.

Return values

→ dictionary[string → double]

The amounts, indexed by fluid names.


remove_fluid{name=…, amount=…, minimum_temperature?=…, maximum_temperature?=…, temperature?=…} → double

Remove fluid from this entity.

If temperature is given only fluid matching that exact temperature is removed. If minimum and maximum is given fluid within that range is removed.

Parameters

Table with the following fields:
name :: string

Fluid prototype name.

Fluid prototype name.

amount :: double

Amount to remove

Amount to remove

minimum_temperature :: double?
maximum_temperature :: double?
temperature :: double?

Return values

→ double

Amount of fluid actually removed.


insert_fluid(fluid) → double

Insert fluid into this entity. Fluidbox is chosen automatically.

Parameters

fluid :: Fluid

Fluid to insert.

Fluid to insert.

Return values

→ double

Amount of fluid actually inserted.


clear_fluid_inside()

Remove all fluids from this entity.


get_beam_source() → BeamTarget?

Get the source of this beam.

Can only be used if this is Beam

set_beam_source(source)

Set the source of this beam.

Parameters

source :: LuaEntity or MapPosition

Can only be used if this is Beam

get_beam_target() → BeamTarget?

Get the target of this beam.

Can only be used if this is Beam

set_beam_target(target)

Set the target of this beam.

Parameters

target :: LuaEntity or MapPosition

Can only be used if this is Beam

get_radius() → double

The radius of this entity.


get_health_ratio() → float?

The health ratio of this entity between 1 and 0 (for full health and no health respectively).

Return values

→ float?

nil if this entity doesn't have health.


create_build_effect_smoke()

Creates the same smoke that is created when you place a building by hand.

You can play the building sound to go with it by using LuaSurface::play_sound, eg: entity.surface.play_sound{path="entity-build/"..entity.prototype.name, position=entity.position}


release_from_spawner()

Release the unit from the spawner which spawned it. This allows the spawner to continue spawning additional units.

Can only be used if this is Unit or SpiderUnit

toggle_equipment_movement_bonus()

Toggle this entity's equipment movement bonus. Does nothing if the entity does not have an equipment grid.

This property can also be read and written on the equipment grid of this entity.


can_shoot(target, position) → boolean

Whether this character can shoot the given entity or position.

Parameters

target :: LuaEntity
position :: MapPosition

Can only be used if this is Character

start_fading_out()

Only works if the entity is a speech-bubble, with an "effect" defined in its wrapper_flow_style. Starts animating the opacity of the speech bubble towards zero, and destroys the entity when it hits zero.

Can only be used if this is SpeechBubble

get_upgrade_target() → LuaEntityPrototype?, LuaQualityPrototype?changed

Returns the new entity prototype and its quality.

Return values

→ LuaEntityPrototype?

nil if this entity is not marked for upgrade.

→ LuaQualityPrototype?

nil if this entity is not marked for upgrade.


get_damage_to_be_taken() → float?

Returns the amount of damage to be taken by this entity.

Return values

→ float?

nil if this entity does not have health.


deplete()

Depletes and destroys this resource entity.

Raised events

Can only be used if this is ResourceEntity

mine{inventory?=…, force?=…, raise_destroyed?=…, ignore_minable?=…} → boolean

Mines this entity.

'Standard' operation is to keep calling LuaEntity.mine with an inventory until all items are transferred and the items dealt with.

The result of mining the entity (the item(s) it produces when mined) will be dropped on the ground if they don't fit into the provided inventory. If no inventory is provided, the items will be destroyed.

Parameters

Table (optional) with the following fields:
inventory :: LuaInventory?

If provided the item(s) will be transferred into this inventory. If provided, this must be an inventory created with LuaGameScript::create_inventory or be a basic inventory owned by some entity.

If provided the item(s) will be transferred into this inventory. If provided, this must be an inventory created with LuaGameScript::create_inventory or be a basic inventory owned by some entity.

force :: boolean?

If true, when the item(s) don't fit into the given inventory the entity is force mined. If false, the mining operation fails when there isn't enough room to transfer all of the items into the inventory. Defaults to false. This is ignored and acts as true if no inventory is provided.

If true, when the item(s) don't fit into the given inventory the entity is force mined. If false, the mining operation fails when there isn't enough room to transfer all of the items into the inventory. Defaults to false. This is ignored and acts as true if no inventory is provided.

raise_destroyed :: boolean?

If true, script_raised_destroy will be raised. Defaults to true.

If true, script_raised_destroy will be raised. Defaults to true.

ignore_minable :: boolean?

If true, the minable state of the entity is ignored. Defaults to false. If false, an entity that isn't minable (set as not-minable in the prototype or isn't minable for other reasons) will fail to be mined.

If true, the minable state of the entity is ignored. Defaults to false. If false, an entity that isn't minable (set as not-minable in the prototype or isn't minable for other reasons) will fail to be mined.

Return values

→ boolean

Whether mining succeeded.

Raised events

script_raised_destroy? instantly

Raised if the raise_destroyed flag was set and the entity was successfully mined.


spawn_decorations()

Triggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or "unit-spawner".


get_priority_target(index) → LuaEntityPrototype?new

Get the entity ID at the specified position in the turret's priority list.

Parameters

index :: uint

The index of the entry to fetch.

The index of the entry to fetch.


set_priority_target(index, entity_id?) new

Set the entity ID name at the specified position in the turret's priority list.

Parameters

index :: uint

The index of the entry to set.

The index of the entry to set.

entity_id :: EntityID?

The name of the entity prototype, or nil to clear the entry.

The name of the entity prototype, or nil to clear the entry.


can_wires_reach(entity) → boolean

Can wires reach between these entities.

Parameters

entity :: LuaEntity


get_connected_rolling_stock(direction) → LuaEntity?, defines.rail_direction?

Gets rolling stock connected to the given end of this stock.

Parameters

direction :: defines.rail_direction

Return values

→ LuaEntity?

The rolling stock connected at the given end, nil if none is connected there.

→ defines.rail_direction?

The rail direction of the connected rolling stock if any.

Can only be used if this is RollingStock

is_registered_for_construction() → boolean

Is this entity or tile ghost or item request proxy registered for construction? If false, it means a construction robot has been dispatched to build the entity, or it is not an entity that can be constructed.


is_registered_for_deconstruction(force) → booleanchanged

Is this entity registered for deconstruction with this force? If false, it means a construction robot has been dispatched to deconstruct it, or it is not marked for deconstruction. The complexity is effectively O(1) - it depends on the number of objects targeting this entity which should be small enough.

Parameters

force :: ForceID

The force construction manager to check.

The force construction manager to check.


is_registered_for_upgrade() → boolean

Is this entity registered for upgrade? If false, it means a construction robot has been dispatched to upgrade it, or it is not marked for upgrade. This is worst-case O(N) complexity where N is the current number of things in the upgrade queue.


is_registered_for_repair() → boolean

Is this entity registered for repair? If false, it means a construction robot has been dispatched to upgrade it, or it is not damaged. This is worst-case O(N) complexity where N is the current number of things in the repair queue.


add_autopilot_destination(position)

Adds the given position to this spidertron's autopilot's queue of destinations.

Parameters

position :: MapPosition

The position the spidertron should move to.

The position the spidertron should move to.

Can only be used if this is SpiderVehicle

connect_linked_belts(neighbour?)

Connects current linked belt with another one.

Neighbours have to be of different type. If given linked belt is connected to something else it will be disconnected first. If provided neighbour is connected to something else it will also be disconnected first. Automatically updates neighbour to be connected back to this one.

Can also be used on entity ghost if it contains linked-belt.

Parameters

neighbour :: LuaEntity?

Another linked belt or entity ghost containing linked belt to connect or nil to disconnect

Another linked belt or entity ghost containing linked belt to connect or nil to disconnect

Can only be used if this is LinkedBelt

disconnect_linked_belts()

Disconnects linked belt from its neighbour.

Can also be used on entity ghost if it contains linked-belt

Can only be used if this is LinkedBelt

get_spider_legs() → array[LuaEntity]

Gets legs of given SpiderVehicle.

Can only be used if this is SpiderVehicle

stop_spider()

Sets the speed of the given SpiderVehicle to zero. Notably does not clear its autopilot_destination, which it will continue moving towards if set.

Can only be used if this is SpiderVehicle

get_wire_connector(wire_connector_id, or_create) → LuaWireConnectornew

Gets a single wire connector of this entity

Parameters

wire_connector_id :: defines.wire_connector_id

Identifier of a specific connector to get

Identifier of a specific connector to get

or_create :: boolean

If true and connector does not exist, it will be allocated if possible

If true and connector does not exist, it will be allocated if possible


get_wire_connectors(or_create) → dictionary[defines.wire_connector_id → LuaWireConnector] new

Gets all wire connectors of this entity

Parameters

or_create :: boolean

If true, it will try to create all connectors possible

If true, it will try to create all connectors possible


get_rail_end(direction) → LuaRailEndnew

Gets a LuaRailEnd object for specified end of this rail

Parameters

direction :: defines.rail_direction

Can only be used if this is Rail

get_electric_input_flow_limit(quality?) → double?new

The input flow limit for the electric energy source. nil if the entity doesn't have an electric energy source.

Parameters

quality :: QualityID?


get_electric_output_flow_limit(quality?) → double?new

The output flow limit for the electric energy source. nil if the entity doesn't have an electric energy source.

Parameters

quality :: QualityID?


get_beacons() → array[LuaEntity]?

Returns a table with all beacons affecting this effect receiver. Can only be used when the entity has an effect receiver (AssemblingMachine, Furnace, Lab, MiningDrills)


get_beacon_effect_receivers() → array[LuaEntity]

Returns a table with all entities affected by this beacon

Can only be used if this is Beacon

force_finish_ascending() new

Take an ascending cargo pod and safely make it skip all animation and immediately switch surface.

Can only be used if this is CargoPod

force_finish_descending() new

Take a descending cargo pod and safely make it arrive and deposit cargo.

Can only be used if this is CargoPod

get_fluid(index) → Fluid?new

Gets fluid of the i-th fluid storage.

Parameters

index :: uint

Fluid storage index. Valid values are from 1 up to LuaEntity::fluids_count.

Fluid storage index. Valid values are from 1 up to LuaEntity::fluids_count.

Return values

→ Fluid?

Fluid in this storage. nil if fluid storage is empty.


set_fluid(index, fluid?) → Fluid?new

Sets fluid to the i-th fluid storage.

Fluid storages that are part of FluidBoxes (also available through LuaFluidBox) may reject some fluids if they do not match filters or are above the FluidBox volume. To verify how much fluid was set a return value can be used which is the same as value that would be returned by LuaEntity::get_fluid.

Parameters

index :: uint

Fluid storage index. Valid values are from 1 up to LuaEntity::fluids_count.

Fluid storage index. Valid values are from 1 up to LuaEntity::fluids_count.

fluid :: Fluid?

Fluid to set. Fluid storage will be cleared if this is not provided.

Fluid to set. Fluid storage will be cleared if this is not provided.

Return values

→ Fluid?

Fluid in this storage after it was set. nil if fluid storage is empty.


get_logistic_sections() → LuaLogisticSections?new

Gives logistic sections of this entity if it uses logistic sections.

Attributes

name :: Read string  

Name of the entity prototype. E.g. "inserter" or "fast-inserter".


ghost_name :: Read string  

Name of the entity or tile contained in this ghost

Can only be used if this is Ghost

localised_name :: Read LocalisedString  

Localised name of the entity.


localised_description :: Read LocalisedString  


ghost_localised_name :: Read LocalisedString  

Localised name of the entity or tile contained in this ghost.

Can only be used if this is Ghost

ghost_localised_description :: Read LocalisedString  

Can only be used if this is Ghost

type :: Read string  

The entity prototype type of this entity.


ghost_type :: Read string  

The prototype type of the entity or tile contained in this ghost.

Can only be used if this is Ghost

use_filters :: Read|Write boolean   new

If set to 'true', this inserter will use filtering logic.

This has no effect if the prototype does not support filters.

Can only be used if this is Inserter

active :: Read|Write boolean  

Deactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will stop moving etc).

Entities that are not active naturally can't be set to be active (setting it to be active will do nothing)

Ghosts, simple smoke, and corpses can't be modified at this time.

It is even possible to set the character to not be active, so he can't move and perform most of the tasks.


destructible :: Read|Write boolean  

If set to false, this entity can't be damaged and won't be attacked automatically. It can however still be mined.

Entities that are indestructible naturally (they have no health, like smoke, resource etc) can't be set to be destructible.


minable :: Read|Write boolean  

Not minable entities can still be destroyed.

Entities that are not minable naturally (like smoke, character, enemy units etc) can't be set to minable.


rotatable :: Read|Write boolean  

When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key.

Entities that are not rotatable naturally (like chest or furnace) can't be set to be rotatable.


operable :: Read|Write boolean  

Player can't open gui of this entity and he can't quick insert/input stuff in to the entity when it is not operable.


health :: Read|Write float  ?

The current health of the entity, if any. Health is automatically clamped to be between 0 and max health (inclusive). Entities with a health of 0 can not be attacked.

To get the maximum possible health of this entity, see LuaEntity::max_health.


max_health :: Read float   new

Max health of this entity.


direction :: Read|Write defines.direction  

The current direction this entity is facing.


mirroring :: Read|Write boolean   new

If the entity is currently mirrored.


supports_direction :: Read boolean  

Whether the entity has direction. When it is false for this entity, it will always return north direction when asked for.


orientation :: Read|Write RealOrientation  

The smooth orientation of this entity.


cliff_orientation :: Read CliffOrientation  

The orientation of this cliff.

Can only be used if this is Cliff

relative_turret_orientation :: Read|Write RealOrientation  ?

The relative orientation of the vehicle turret, artillery turret, artillery wagon. nil if this entity isn't a vehicle with a vehicle turret or artillery turret/wagon.

Writing does nothing if the vehicle doesn't have a turret.


torso_orientation :: Read|Write RealOrientation  

The torso orientation of this spider vehicle.

Can only be used if this is SpiderVehicle

amount :: Read|Write uint  

Count of resource units contained.

Can only be used if this is ResourceEntity

initial_amount :: Read|Write uint  ?

Count of initial resource units contained. nil if this is not an infinite resource.

If this is not an infinite resource, writing will produce an error.

Can only be used if this is ResourceEntity

effectivity_modifier :: Read|Write float  

Multiplies the acceleration the vehicle can create for one unit of energy. Defaults to 1.

Can only be used if this is Car

consumption_modifier :: Read|Write float  

Multiplies the energy consumption.

Can only be used if this is Car

friction_modifier :: Read|Write float  

Multiplies the car friction rate.

Can only be used if this is Car

Example

-- This will allow the car to go much faster
game.player.vehicle.friction_modifier = 0.5

driver_is_gunner :: Read|Write boolean  ?

Whether the driver of this car or spidertron is the gunner. If false, the passenger is the gunner. nil if this is neither a car or a spidertron.

Can only be used if this is Car or SpiderVehicle

vehicle_automatic_targeting_parameters :: Read|Write VehicleAutomaticTargetingParameters  

Read when this spidertron auto-targets enemies

Can only be used if this is SpiderVehicle

speed :: Read|Write float  ?

The current speed if this is a car, rolling stock, projectile or spidertron, or the maximum speed if this is a unit. The speed is in tiles per tick. nil if this is not a car, rolling stock, unit, projectile or spidertron.

Only the speed of units, cars, and projectiles are writable.


effective_speed :: Read float  ?

The current speed of this unit in tiles per tick, taking into account any walking speed modifier given by the tile the unit is standing on. nil if this is not a unit.

Can only be used if this is Unit

stack :: Read LuaItemStack  

Can only be used if this is ItemEntity

prototype :: Read LuaEntityPrototype  

The entity prototype of this entity.


ghost_prototype :: Read LuaEntityPrototype or LuaTilePrototype  

The prototype of the entity or tile contained in this ghost.

Can only be used if this is Ghost

drop_position :: Read|Write MapPosition  

Position where the entity puts its stuff.

Mining drills and crafting machines can't have their drop position changed; inserters must have allow_custom_vectors set to true on their prototype to allow changing the drop position.

Meaningful only for entities that put stuff somewhere, such as mining drills, crafting machines with a drop target or inserters.


pickup_position :: Read|Write MapPosition  

Where the inserter will pick up items from.

Inserters must have allow_custom_vectors set to true on their prototype to allow changing the pickup position.

Can only be used if this is Inserter

drop_target :: Read|Write LuaEntity  ?

The entity this entity is putting its items to. If there are multiple possible entities at the drop-off point, writing to this attribute allows a mod to choose which one to drop off items to. The entity needs to collide with the tile box under the drop-off position. nil if there is no entity to put items to, or if this is not an entity that puts items somewhere.


pickup_target :: Read|Write LuaEntity  ?

The entity this inserter will attempt to pick up items from. If there are multiple possible entities at the pick-up point, writing to this attribute allows a mod to choose which one to pick up items from. The entity needs to collide with the tile box under the pick-up position. nil if there is no entity to pull items from.

Can only be used if this is Inserter

selected_gun_index :: Read|Write uint  ?

Index of the currently selected weapon slot of this character, car, or spidertron. nil if this entity doesn't have guns.

Can only be used if this is Character or Car or SpiderVehicle

energy :: Read|Write double  

Energy stored in the entity's energy buffer (energy stored in electrical devices etc.). Always 0 for entities that don't have the concept of energy stored inside.

Example

game.player.print("Machine energy: " .. game.player.selected.energy .. "J")
game.player.selected.energy = 3000

temperature :: Read|Write double  ?

The temperature of this entity's heat energy source. nil if this entity does not use a heat energy source.


previous_recipe :: Read RecipeIDAndQualityIDPair  ?changed

The previous recipe this furnace was using, if any.

Can only be used if this is Furnace

held_stack :: Read LuaItemStack  

The item stack currently held in an inserter's hand.

Can only be used if this is Inserter

held_stack_position :: Read MapPosition  

Current position of the inserter's "hand".

Can only be used if this is Inserter

train :: Read LuaTrain  ?

The train this rolling stock belongs to, if any. nil if this is not a rolling stock.


neighbours :: Read dictionary[string → array[LuaEntity]] or array[array[LuaEntity]] or LuaEntity  ?

A list of neighbours for certain types of entities. Applies to underground belts, walls, gates, reactors, cliffs, and pipe-connectable entities.

Differs depending on the type of entity:
  • When called on a pipe-connectable entity, this is an array of entity arrays of all entities a given fluidbox is connected to.
  • When called on an underground transport belt, this is the other end of the underground belt connection, or nil if none.
  • When called on a wall-connectable entity or reactor, this is a dictionary of all connections indexed by the connection direction "north", "south", "east", and "west".
  • When called on a cliff entity, this is a dictionary of all connections indexed by the connection direction "north", "south", "east", and "west".

belt_neighbours :: Read table  

The belt connectable neighbours of this belt connectable entity. Only entities that input to or are outputs of this entity. Does not contain the other end of an underground belt, see LuaEntity::neighbours for that.

Table fields

inputs :: array[LuaEntity]

Array of transport belt connectable entities.

Array of transport belt connectable entities.

outputs :: array[LuaEntity]

Array of transport belt connectable entities.

Array of transport belt connectable entities.

Can only be used if this is TransportBeltConnectable

fluidbox :: Read LuaFluidBox   changed

Fluidboxes of this entity.


backer_name :: Read|Write string  ?

The backer name assigned to this entity. Entities that support backer names are labs, locomotives, radars, roboports, and train stops. nil if this entity doesn't support backer names.

While train stops get the name of a backer when placed down, players can rename them if they want to. In this case, backer_name returns the player-given name of the entity.

Raised events


entity_label :: Read|Write string  ?

The label on this spider-vehicle entity, if any. nil if this is not a spider-vehicle.

Raised events


time_to_live :: Read|Write uint64   changed

The ticks left before a combat robot, highlight box, smoke, or sticker entity is destroyed.

Can only be used if this is CombatRobot or HighlightBox or Smoke or Sticker

color :: Read|Write Color  ?

The color of this character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner. nil if this entity doesn't use custom colors.

Car color is overridden by the color of the current driver/passenger, if there is one.


signal_state :: Read defines.signal_state  

The state of this rail signal.

Can only be used if this is RailSignal or RailChainSignal

chain_signal_state :: Read defines.chain_signal_state  

The state of this chain signal.

Can only be used if this is RailChainSignal

to_be_looted :: Read|Write boolean  

Will this item entity be picked up automatically when the player walks over it?

Can only be used if this is ItemEntity

crafting_speed :: Read double  

The current crafting speed, including speed bonuses from modules and beacons.

Can only be used if this is CraftingMachine

crafting_progress :: Read|Write float  

The current crafting progress, as a number in range [0, 1].

Can only be used if this is CraftingMachine

bonus_progress :: Read|Write double  

The current productivity bonus progress, as a number in range [0, 1].

Can only be used if this is CraftingMachine

result_quality :: Read LuaQualityPrototype | Write QualityID  ?new

The quality produced when this crafting machine finishes crafting. nil when crafting is not in progress.

Note: Writing nil is not allowed.

Can only be used if this is CraftingMachine

productivity_bonus :: Read double  

The productivity bonus of this entity.

This includes force based bonuses as well as beacon/module bonuses.


pollution_bonus :: Read double  

The pollution bonus of this entity.


speed_bonus :: Read double  

The speed bonus of this entity.

This includes force based bonuses as well as beacon/module bonuses.


consumption_bonus :: Read double  

The consumption bonus of this entity.


belt_to_ground_type :: Read "input" or "output"  

Whether this underground belt goes into or out of the ground.

Can only be used if this is UndergroundBelt

loader_type :: Read|Write "input" or "output"  

Whether this loader gets items from or puts item into a container.

Can only be used if this is Loader

rocket_parts :: Read|Write uint  

Number of rocket parts in the silo.

Can only be used if this is RocketSilo

logistic_network :: Read|Write LuaLogisticNetwork  

The logistic network this entity is a part of, or nil if this entity is not a part of any logistic network.


logistic_cell :: Read LuaLogisticCell  

The logistic cell this entity is a part of. Will be nil if this entity is not a part of any logistic cell.


item_requests :: Read array[ItemCountWithQuality]   changed

Items this ghost will request when revived or items this item request proxy is requesting.


insert_plan :: Read|Write array[BlueprintInsertPlan]   new

The insert plan for this ghost or item request proxy.

Can only be used if this is EntityGhost or ItemRequestProxy

removal_plan :: Read|Write array[BlueprintInsertPlan]   new

The removal plan for this item request proxy.

Can only be used if this is ItemRequestProxy

player :: Read LuaPlayer  ?

The player connected to this character, if any.

Can only be used if this is Character

damage_dealt :: Read|Write double  

The damage dealt by this turret, artillery turret, or artillery wagon.

Can only be used if this is Turret

kills :: Read|Write uint  

The number of units killed by this turret, artillery turret, or artillery wagon.

Can only be used if this is Turret

ignore_unprioritised_targets :: Read|Write boolean   new

Whether this turret shoots at targets that are not on its priority list.

Can only be used if this is Turret

last_user :: Read|Write LuaPlayer or PlayerIdentification  ?

The last player that changed any setting on this entity. This includes building the entity, changing its color, or configuring its circuit network. nil if the last user is not part of the save anymore.

Reading this property will return a LuaPlayer, while PlayerIdentification can be used when writing.

Can only be used if this is EntityWithOwner or DeconstructibleTileProxy or TileGhost

electric_buffer_size :: Read|Write double  ?

The buffer size for the electric energy source. nil if the entity doesn't have an electric energy source.

Write access is limited to the ElectricEnergyInterface type.


electric_drain :: Read double  ?

The electric drain for the electric energy source. nil if the entity doesn't have an electric energy source.


electric_emissions_per_joule :: Read dictionary[string → double]  ?new

The table of emissions of this energy source in pollution/Joule, indexed by pollutant type. nil if the entity doesn't have an electric energy source. Multiplying values in the returned table by energy consumption in Watt gives pollution/second.


unit_number :: Read uint  ?

A unique number identifying this entity for the lifetime of the save. These are allocated sequentially, and not re-used (until overflow).

Only entities inheriting from EntityWithOwnerPrototype, as well as ItemRequestProxyPrototype and EntityGhostPrototype are assigned a unit number. Returns nil otherwise.


ghost_unit_number :: Read uint  ?

The unit_number of the entity contained in this ghost. It is the same as the unit number of the EntityWithOwnerPrototype that was destroyed to create this ghost. If it was created by other means, or if the inner entity does not support unit numbers, this property is nil.

Can only be used if this is EntityGhost

mining_progress :: Read|Write double  ?

The mining progress for this mining drill. Is a number in range [0, mining_target.prototype.mineable_properties.mining_time]. nil if this isn't a mining drill.


bonus_mining_progress :: Read|Write double  ?

The bonus mining progress for this mining drill. Read yields a number in range [0, mining_target.prototype.mineable_properties.mining_time]. nil if this isn't a mining drill.


power_production :: Read|Write double  

The power production specific to the ElectricEnergyInterface entity type.

Can only be used if this is ElectricEnergyInterface

power_usage :: Read|Write double  

The power usage specific to the ElectricEnergyInterface entity type.

Can only be used if this is ElectricEnergyInterface

bounding_box :: Read BoundingBox  

LuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation.


secondary_bounding_box :: Read BoundingBox  ?

The secondary bounding box of this entity or nil if it doesn't have one. This only exists for curved rails, and is automatically determined by the game.


selection_box :: Read BoundingBox  

LuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation.


secondary_selection_box :: Read BoundingBox  ?

The secondary selection box of this entity or nil if it doesn't have one. This only exists for curved rails, and is automatically determined by the game.


mining_target :: Read LuaEntity  ?

The mining target, if any.

Can only be used if this is MiningDrill

filter_slot_count :: Read uint  

The number of filter slots this inserter, loader, mining drill or logistic storage container has. 0 if not one of those entities.


loader_container :: Read LuaEntity  ?

The container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type, if any.

Can only be used if this is Loader

grid :: Read LuaEquipmentGrid  ?

This entity's equipment grid, if any.


graphics_variation :: Read|Write uint8  ?

The graphics variation for this entity. nil if this entity doesn't use graphics variations.


tree_color_index :: Read|Write uint8  

Index of the tree color.

Can only be used if this is Tree

tree_color_index_max :: Read uint8  

Maximum index of the tree colors.

Can only be used if this is Tree

tree_stage_index :: Read|Write uint8  

Index of the tree stage.

Can only be used if this is Tree

tree_stage_index_max :: Read uint8  

Maximum index of the tree stages.

Can only be used if this is Tree

tree_gray_stage_index :: Read|Write uint8  

Index of the tree gray stage

Can only be used if this is Tree

tree_gray_stage_index_max :: Read uint8  

Maximum index of the tree gray stages.

Can only be used if this is Tree

burner :: Read LuaBurner  ?

The burner energy source for this entity, if any.


shooting_target :: Read|Write LuaEntity  ?

The shooting target for this turret, if any. Can't be set to nil via script.

Can only be used if this is Turret

proxy_target :: Read LuaEntity  ?

The target entity for this item-request-proxy, if any.

Can only be used if this is ItemRequestProxy

stickers :: Read array[LuaEntity]  ?

The sticker entities attached to this entity, if any.


sticked_to :: Read LuaEntity  

The entity this sticker is sticked to.

Can only be used if this is Sticker

sticker_vehicle_modifiers :: Read table  ?changed

The vehicle modifiers applied to this entity through the attached stickers.

Table fields

speed_modifier :: double
speed_max :: double
friction_modifier :: double


parameters :: Read|Write ProgrammableSpeakerParameters  

Can only be used if this is ProgrammableSpeaker

alert_parameters :: Read|Write ProgrammableSpeakerAlertParameters  

Can only be used if this is ProgrammableSpeaker

electric_network_statistics :: Read LuaFlowStatistics  

The electric network statistics for this electric pole.

Can only be used if this is ElectricPole

inserter_target_pickup_count :: Read uint  

Returns the current target pickup count of the inserter.

This considers the circuit network, manual override and the inserter stack size limit based on technology.

Can only be used if this is Inserter

inserter_stack_size_override :: Read|Write uint  

Sets the stack size limit on this inserter. If the stack size is > than the force stack size limit the value is ignored.

Set to 0 to reset.

Can only be used if this is Inserter

products_finished :: Read|Write uint  

The number of products this machine finished crafting in its lifetime.

Can only be used if this is CraftingMachine

spawning_cooldown :: Read double  

Can only be used if this is Spawner

absorbed_pollution :: Read double  

Can only be used if this is Spawner

spawn_shift :: Read double  

Can only be used if this is Spawner

units :: Read array[LuaEntity]  

The units associated with this spawner entity.

Can only be used if this is Spawner

power_switch_state :: Read|Write boolean  

The state of this power switch.

Can only be used if this is PowerSwitch

combinator_description :: Read|Write string   new

The description on this combinator


effects :: Read ModuleEffects  ?

The effects being applied to this entity, if any. For beacons, this is the effect the beacon is broadcasting.


beacons_count :: Read uint  ?

Number of beacons affecting this effect receiver. Can only be used when the entity has an effect receiver (AssemblingMachine, Furnace, Lab, MiningDrills)


infinity_container_filters :: Read|Write array[InfinityInventoryFilter]  

The filters for this infinity container.

Can only be used if this is InfinityContainer

remove_unfiltered_items :: Read|Write boolean  

Whether items not included in this infinity container filters should be removed from the container.

Can only be used if this is InfinityContainer

character_corpse_player_index :: Read|Write uint  

The player index associated with this character corpse.

The index is not guaranteed to be valid so it should always be checked first if a player with that index actually exists.

Can only be used if this is CharacterCorpse

character_corpse_tick_of_death :: Read|Write uint  

The tick this character corpse died at.

Can only be used if this is CharacterCorpse

character_corpse_death_cause :: Read|Write LocalisedString  

The reason this character corpse character died. "" if there is no reason.

Can only be used if this is CharacterCorpse

associated_player :: Read|Write LuaPlayer or PlayerIdentification  ?

The player this character is associated with, if any. Set to nil to clear.

The player will be automatically disassociated when a controller is set on the character. Also, all characters associated to a player will be logged off when the player logs off in multiplayer.

Reading this property will return a LuaPlayer, while PlayerIdentification can be used when writing.

A character associated with a player is not directly controlled by any player.

Can only be used if this is Character

tick_of_last_attack :: Read|Write uint  

The last tick this character entity was attacked.

Can only be used if this is Character

tick_of_last_damage :: Read|Write uint  

The last tick this character entity was damaged.

Can only be used if this is Character

splitter_filter :: Read|Write ItemFilter  ?changed

The filter for this splitter, if any is set.

Can only be used if this is Splitter or LaneSplitter

inserter_filter_mode :: Read|Write "whitelist" or "blacklist"  ?

The filter mode for this filter inserter. nil if this inserter doesn't use filters.

Can only be used if this is Inserter

loader_filter_mode :: Read|Write "none" or "whitelist" or "blacklist"  ?new

The filter mode for this loader. nil if this loader does not support filters.

Can only be used if this is Loader

mining_drill_filter_mode :: Read|Write "whitelist" or "blacklist"  ?new

The filter mode for this mining drill. nil if this mining drill doesn't have filters.

Can only be used if this is MiningDrill

splitter_input_priority :: Read|Write "left" or "none" or "right"  

The input priority for this splitter.

Can only be used if this is Splitter or LaneSplitter

splitter_output_priority :: Read|Write "left" or "none" or "right"  

The output priority for this splitter.

Can only be used if this is Splitter or LaneSplitter

armed :: Read boolean  

Whether this land mine is armed.

Can only be used if this is LandMine

recipe_locked :: Read|Write boolean  

When locked; the recipe in this assembling machine can't be changed by the player.

Can only be used if this is AssemblingMachine

connected_rail :: Read LuaEntity  ?

The rail entity this train stop is connected to, if any.

Can only be used if this is TrainStop

connected_rail_direction :: Read defines.rail_direction  

Rail direction to which this train stop is binding. This returns a value even when no rails are present.

Can only be used if this is TrainStop

trains_in_block :: Read uint  

The number of trains in this rail block for this rail entity.

Can only be used if this is Rail

timeout :: Read|Write uint  

The timeout that's left on this landmine in ticks. It describes the time between the landmine being placed and it being armed.

Can only be used if this is LandMine

neighbour_bonus :: Read double  

The current total neighbour bonus of this reactor.

Can only be used if this is Reactor

ai_settings :: Read LuaAISettings  

The ai settings of this unit.

Can only be used if this is Unit or SpiderUnit

highlight_box_type :: Read|Write CursorBoxRenderType  

The highlight box type of this highlight box entity.

Can only be used if this is HighlightBox


status :: Read defines.entity_status  ?

The status of this entity, if any.

This is always the actual status of the entity, even if LuaEntity::custom_status is set.


custom_status :: Read|Write CustomEntityStatus  ?new

A custom status for this entity that will be displayed in the GUI.


enable_logistics_while_moving :: Read|Write boolean  

Whether equipment grid logistics are enabled while this vehicle is moving.

Can only be used if this is Vehicle

render_player :: Read|Write LuaPlayer or PlayerIdentification  ?

The player that this simple-entity-with-owner, simple-entity-with-force, or highlight-box is visible to. nil when this entity is rendered for all players.

Reading this property will return a LuaPlayer, while PlayerIdentification can be used when writing.


render_to_forces :: Read|Write ForceSet  ?changed

The forces that this simple-entity-with-owner or simple-entity-with-force is visible to. nil or an empty array when this entity is rendered for all forces.

Reading will always give an array of LuaForce


pump_rail_target :: Read LuaEntity  ?

The rail target of this pump, if any.

Can only be used if this is Pump

electric_network_id :: Read uint  ?

Returns the id of the electric network that this entity is connected to, if any.


allow_dispatching_robots :: Read|Write boolean  

Whether this character's personal roboports are allowed to dispatch robots.

Can only be used if this is Character

energy_generated_last_tick :: Read double  

How much energy this generator generated in the last tick.

Can only be used if this is Generator

storage_filter :: Read|Write LuaItemPrototype  ?

The storage filter for this logistic storage container.

Useable only on logistic containers with the "storage" logistic_mode.


request_from_buffers :: Read|Write boolean  

Whether this requester chest is set to also request from buffer chests.

Useable only on entities that have requester slots.


corpse_expires :: Read|Write boolean  

Whether this corpse will ever fade away.

Can only be used if this is Corpse

corpse_immune_to_entity_placement :: Read|Write boolean  

If true, corpse won't be destroyed when entities are placed over it. If false, whether corpse will be removed or not depends on value of CorpsePrototype::remove_on_entity_placement.

Can only be used if this is Corpse

tags :: Read|Write Tags  ?

The tags associated with this entity ghost. nil if this is not an entity ghost.


time_to_next_effect :: Read|Write uint  

The ticks until the next trigger effect of this smoke-with-trigger.

Can only be used if this is SmokeWithTrigger

autopilot_destination :: Read|Write MapPosition  ?

Destination of this spidertron's autopilot, if any. Writing nil clears all destinations.

Can only be used if this is SpiderVehicle

autopilot_destinations :: Read array[MapPosition]  

The queued destination positions of spidertron's autopilot.

Can only be used if this is SpiderVehicle

trains_count :: Read uint  

Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint.

Train may be included multiple times when braking distance covers this train stop multiple times.

Value may be read even when train stop has no control behavior.

Can only be used if this is TrainStop

trains_limit :: Read|Write uint  

Amount of trains above which no new trains will be sent to this train stop. Writing nil will disable the limit (will set a maximum possible value).

When a train stop has a control behavior with wire connected and set_trains_limit enabled, this value will be overwritten by it.

Can only be used if this is TrainStop

is_military_target :: Read|Write boolean  

Whether this entity is a MilitaryTarget. Can be written to if LuaEntityPrototype::allow_run_time_change_of_is_military_target returns true.


is_entity_with_owner :: Read boolean  

If this entity is EntityWithOwner


is_entity_with_health :: Read boolean  

If this entity is EntityWithHealth


combat_robot_owner :: Read|Write LuaEntity  ?

The owner of this combat robot, if any.

Can only be used if this is CombatRobot


follow_target :: Read|Write LuaEntity  ?

The follow target of this spidertron, if any.

Can only be used if this is SpiderVehicle

follow_offset :: Read|Write Vector  ?

The follow offset of this spidertron, if any entity is being followed. This is randomized each time the follow entity is set.

Can only be used if this is SpiderVehicle

linked_belt_type :: Read|Write "input" or "output"  

Type of linked belt. Changing type will also flip direction so the belt is out of the same side.

Can only be changed when linked belt is disconnected (has no neighbour set).

Can also be used on entity ghost if it contains linked-belt.

Can only be used if this is LinkedBelt

linked_belt_neighbour :: Read LuaEntity  ?

Neighbour to which this linked belt is connected to, if any.

Can also be used on entity ghost if it contains linked-belt.

May return entity ghost which contains linked belt to which connection is made.

Can only be used if this is LinkedBelt

quality :: Read LuaQualityPrototype   new

The quality of this entity.

Not all entities support quality and will give the "normal" quality back if they don't.


rail_layer :: Read defines.rail_layer   new

Gets rail layer of a given signal

Can only be used if this is RailSignal or RailChainSignal

radar_scan_progress :: Read float  

The current radar scan progress, as a number in range [0, 1].

Can only be used if this is Radar

name_tag :: Read|Write string   new

Name tag of this entity. Returns nil if entity has no name tag. When name tag is already used by other entity, the name will be removed from the other entity. Entity name tags can also be set in the entity "extra settings" GUI in the map editor.


rocket_silo_status :: Read defines.rocket_silo_status  

The status of this rocket silo entity.

Can only be used if this is RocketSilo

tile_width :: Read uint  

Specifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). Uses the current direction of the entity.


tile_height :: Read uint  

Specifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). Uses the current direction of the entity.


crane_destination :: Read|Write MapPosition   new

Destination of the crane of this entity. Throws when trying to set the destination out of range.

Can only be used if this is AgriculturalTower

crane_destination_3d :: Read|Write Vector3D   new

Destination of the crane of this entity in 3D. Throws when trying to set the destination out of range.

Can only be used if this is AgriculturalTower

crane_grappler_destination :: Write MapPosition   new

Will set destination for the grappler of crane of this entity. The crane grappler will start moving to reach the destination, but the rest of the arm will remain stationary. Throws when trying to set the destination out of range.

Can only be used if this is AgriculturalTower

crane_grappler_destination_3d :: Write Vector3D   new

Will set destination in 3D for the grappler of crane of this entity. The crane grappler will start moving to reach the destination, but the rest of the arm will remain stationary. Throws when trying to set the destination out of range.

Can only be used if this is AgriculturalTower

copy_color_from_train_stop :: Read|Write boolean   new

If this RollingStock has 'copy color from train stop' enabled.

Can only be used if this is RollingStock

is_headed_to_trains_front :: Read boolean  

If the rolling stock is facing train's front.

Can only be used if this is RollingStock

draw_data :: Read RollingStockDrawData  

Gives a draw data of the given entity if it supports such data.

Can only be used if this is RollingStock

train_stop_priority :: Read|Write uint8   new

Priority of this train stop.

Can only be used if this is TrainStop

belt_shape :: Read "straight" or "left" or "right"  

Gives what is the current shape of a transport-belt.

Can also be used on entity ghost if it contains transport-belt.

Can only be used if this is TransportBelt

gps_tag :: Read string  

Returns a rich text string containing this entity's position and surface name as a gps tag. Printing it will ping the location of the entity.

Example

-- called on a LuaEntity on the default surface it returns:
entity.gps_tag -- => "[gps=-4,-9]"

-- called on a LuaEntity on "custom-surface" it returns:
different_entity.gps_tag -- => "[gps=1,-5,custom-surface]"

commandable :: Read LuaCommandable  ?new

Returns a LuaCommandable for this entity or nil if entity is not commandable.


fluids_count :: Read uint   new

Returns count of fluid storages. This includes fluid storages provided by FluidBoxes but also covers other fluid storages like FluidTurret's internal buffer and FluidWagon's fluid since they are not FluidBox and cannot be exposed through LuaFluidBox.


tick_grown :: Read|Write MapTick   new

The tick when this plant is fully grown.

Can only be used if this is Plant

always_on :: Read|Write boolean   new

If the lamp is always on when not driven by control behavior.

Can only be used if this is Lamp

artillery_auto_targeting :: Read|Write boolean   new

If this artillery auto-targets enemies.

Can only be used if this is ArtilleryWagon or ArtilleryTurret

robot_order_queue :: Read array[WorkerRobotOrder]   new

Get the current queue of robot orders.

Can only be used if this is ConstructionRobot or LogisticRobot

cargo_pod :: Read LuaEntity  ?new

Gets the cargo pod attached to this rocket silo rocket if one exists.

Can only be used if this is RocketSiloRocket

procession_tick :: Read|Write MapTick   new

how far into the current procession the cargo pod is.

Can only be used if this is CargoPod

valid :: Read boolean  

Is this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.


object_name :: Read string  

The class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.

Classes

Concepts

Events

Defines