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.
get_output_inventory() → LuaInventory | Gets the entities output inventory if it has one. |
get_module_inventory() → LuaInventory | |
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, dealer) → float | Damages the entity. |
can_be_destroyed() → boolean | Checks if the entity can be destroyed |
destroy{do_cliff_correction = …, raise_destroy = …} → boolean | Destroys the entity. |
set_command(command) | Give the entity a command. |
set_distraction_command(command) | Give the entity a distraction command. |
has_command() → boolean | Has this unit been assigned a command? |
die(force, cause) → boolean | Immediately kills the entity. |
has_flag(flag) → boolean | Test whether this entity's prototype has a flag set. |
ghost_has_flag(flag) → boolean | Same as LuaEntity::has_flag but targets the inner entity on a entity ghost. |
add_market_item(offer) | Offer a thing on the market. |
remove_market_item(offer) → boolean | Remove an offer from a market. |
get_market_items() → array[Offer] | Get all offers in a market as an array. |
clear_market_items() | Removes all offers from a market. |
connect_neighbour(target) → boolean | Connect two devices with a circuit wire or copper cable. |
disconnect_neighbour(target) | Disconnect circuit wires or copper cables between devices. |
order_deconstruction(force, player) → boolean | Sets the entity to be deconstructed by construction robots. |
cancel_deconstruction(force, player) | Cancels deconstruction if it is scheduled, does nothing otherwise. |
to_be_deconstructed() → boolean | Is this entity marked for deconstruction? |
order_upgrade{force = …, target = …, player = …, direction = …} → boolean | Sets the entity to be upgraded by construction robots. |
cancel_upgrade(force, player) → boolean | Cancels upgrade if it is scheduled, does nothing otherwise. |
to_be_upgraded() → boolean | Is this entity marked for upgrade? |
get_request_slot(slot) → SimpleItemStack | Get a logistic requester slot. |
set_request_slot(request, slot) → boolean | Set a logistic requester slot. |
clear_request_slot(slot) | Clear a logistic requester slot. |
is_crafting() | 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) | |
request_to_close(force) | |
get_transport_line(index) → LuaTransportLine | Get a transport line of a belt or belt connectable entity. |
get_max_transport_line_index() → uint | 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] | Revive a ghost. |
silent_revive{return_item_request_proxy = …, raise_revive = …} → dictionary[string → uint] | Revives a ghost silently. |
get_connected_rail{rail_direction = …, rail_connection_direction = …} → LuaEntity | |
get_connected_rails() → array[LuaEntity] | Get the rails that this signal is connected to. |
get_rail_segment_entity(direction, in_else_out) → LuaEntity | Get the rail signal or train stop at the start/end of the rail segment this rail is in, or nil if the rail segment doesn't start/end with a signal nor a train stop. |
get_rail_segment_end(direction) → LuaEntity | Get the rail at the end of the rail segment this rail is in. |
get_rail_segment_length() → double | 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_filter(slot_index) → string | Get the filter for a slot in an inserter, loader, or logistic storage container. |
set_filter(slot_index, item) | Set the filter for a slot in an inserter, loader, or logistic storage container. |
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. |
set_infinity_container_filter(index, filter) | 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. |
set_infinity_pipe_filter(filter) | Sets the filter for this infinity pipe. |
get_heat_setting() → HeatSetting | Gets the heat setting for this heat interface. |
set_heat_setting(filter) | Sets the heat setting for this heat interface. |
get_control_behavior() → LuaControlBehavior | 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. |
get_circuit_network(wire, circuit_connector) → LuaCircuitNetwork | |
get_merged_signal(signal, circuit_connector) → int | Read a single signal from the combined circuit networks. |
get_merged_signals(circuit_connector) → array[Signal] | The merged circuit network signals or nil if there are no signals. |
supports_backer_name() → boolean | Whether this entity supports a backer name. |
copy_settings(entity, by_player) → dictionary[string → uint] | Copies settings from the given entity onto this entity. |
get_logistic_point(index) → LuaLogisticPoint or array[LuaLogisticPoint] | Gets all the LuaLogisticPoint s that this entity owns. |
play_note(instrument, note) → boolean | Plays a note with the given instrument and note. |
connect_rolling_stock(direction) → boolean | Connects the rolling stock in the given direction. |
disconnect_rolling_stock(direction) → boolean | 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. |
get_recipe() → LuaRecipe | Current recipe being assembled by this machine or nil if no recipe is set. |
set_recipe(recipe) → dictionary[string → uint] | Sets the current recipe in this assembly machine. |
rotate{reverse = …, by_player = …, spill_items = …, enable_looted = …, force = …} → boolean | Rotates this entity as if the player rotated it. |
get_driver() → LuaEntity or LuaPlayer | Gets the driver of this vehicle if any. |
set_driver(driver) | Sets the driver of this vehicle. |
get_passenger() → LuaEntity or LuaPlayer | Gets the passenger of this car or spidertron if any. |
set_passenger(passenger) | Sets the passenger of this car or spidertron. |
is_connected_to_electric_network() → boolean | Returns true if this entity is connected to an electric network. |
get_train_stop_trains() → array[LuaTrain] | The trains scheduled to stop at this train stop. |
get_stopped_train() → LuaTrain | The train currently stopped at this train stop or nil if none. |
clone{position = …, surface = …, force = …, create_build_effect_smoke = …} → LuaEntity | Clones this entity. |
get_fluid_count(fluid) → double | 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. |
remove_fluid{name = …, amount = …, minimum_temperature = …, maximum_temperature = …, temperature = …} → double | Remove fluid from this entity. |
insert_fluid(fluid) → double | Insert fluid into this entity. |
clear_fluid_inside() | Remove all fluids from this entity. |
get_beam_source() → BeamTarget | Get the source of this beam. |
set_beam_source(source) | Set the source of this beam. |
get_beam_target() → BeamTarget | Get the target of this beam. |
set_beam_target(target) | Set the target of this 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). |
create_build_effect_smoke() | 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. |
toggle_equipment_movement_bonus() | Toggle this entity's equipment movement bonus. |
can_shoot(target, position) → boolean | If 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. |
get_upgrade_target() → LuaEntityPrototype | Returns the new entity prototype. |
get_upgrade_direction() → defines.direction | Returns the new entity direction after upgrading. |
get_damage_to_be_taken() → float | Returns the amount of damage to be taken by this entity. |
deplete() | Depletes and destroys this resource entity. |
mine{inventory = …, force = …, raise_destroyed = …, ignore_minable = …} → boolean | 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". |
can_wires_reach(entity) → boolean | Can wires reach between these entities. |
get_connected_rolling_stock(direction) → LuaEntity | 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_registered_for_deconstruction(force) → boolean | Is this entity registered for deconstruction with this force? |
is_registered_for_upgrade() → boolean | Is this entity registered for upgrade? |
is_registered_for_repair() → boolean | Is this entity registered for repair? |
add_autopilot_destination(position) | Adds the given position to this spidertron's autopilot's queue of destinations. |
connect_linked_belts(neighbour) | Connects current linked belt with another one. |
disconnect_linked_belts() | Disconnects linked belt from its neighbour. |
name :: string [R] | Name of the entity prototype. |
ghost_name :: string [R] | Name of the entity or tile contained in this ghost |
localised_name :: LocalisedString [R] | Localised name of the entity. |
localised_description :: LocalisedString [R] | |
ghost_localised_name :: LocalisedString [R] | Localised name of the entity or tile contained in this ghost. |
ghost_localised_description :: LocalisedString [R] | |
type :: string [R] | The entity prototype type of this entity. |
ghost_type :: string [R] | The prototype type of the entity or tile contained in this ghost. |
active :: boolean [RW] | Deactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will stop moving etc). |
destructible :: boolean [RW] | When the entity is not destructible it can't be damaged. |
minable :: boolean [RW] | |
rotatable :: boolean [RW] | When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key. |
operable :: boolean [RW] | 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 :: float [RW] | The current health of the entity, or nil if it doesn't have health. |
direction :: defines.direction [RW] | The current direction this entity is facing. |
supports_direction :: boolean [R] | Whether the entity has direction. |
orientation :: RealOrientation [RW] | The smooth orientation of this entity, if it supports orientation. |
cliff_orientation :: CliffOrientation [R] | The orientation of this cliff. |
relative_turret_orientation :: RealOrientation [RW] | The relative orientation of the vehicle turret, artillery turret, artillery wagon
or nil if this entity isn't a vehicle with a vehicle turret or artillery turret/wagon. |
torso_orientation :: RealOrientation [RW] | The torso orientation of this spider vehicle. |
amount :: uint [RW] | Count of resource units contained. |
initial_amount :: uint [RW] | Count of initial resource units contained. |
effectivity_modifier :: float [RW] | Multiplies the acceleration the vehicle can create for one unit of energy. |
consumption_modifier :: float [RW] | Multiplies the energy consumption. |
friction_modifier :: float [RW] | Multiplies the car friction rate. |
driver_is_gunner :: boolean [RW] | Whether the driver of this car or spidertron is the gunner, if false, the passenger is the gunner. |
vehicle_automatic_targeting_parameters :: VehicleAutomaticTargetingParameters [RW] | Read when this spidertron auto-targets enemies |
speed :: float [RW] | The current speed of this car in tiles per tick, rolling stock, projectile or spider vehicle, or current max speed of the unit. |
effective_speed :: float [R] | 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 :: LuaItemStack [R] | |
prototype :: LuaEntityPrototype [R] | The entity prototype of this entity. |
ghost_prototype :: LuaEntityPrototype or LuaTilePrototype [R] | The prototype of the entity or tile contained in this ghost. |
drop_position :: Position [RW] | Position where the entity puts its stuff. |
pickup_position :: Position [RW] | Where the inserter will pick up items from. |
drop_target :: LuaEntity [RW] | The entity this entity is putting its stuff to or nil if there is no such entity. |
pickup_target :: LuaEntity [RW] | The entity the inserter will attempt to pick up from. |
selected_gun_index :: uint [RW] | Index of the currently selected weapon slot of this character, car, or spidertron, or nil if the car/spidertron doesn't have guns. |
energy :: double [RW] | Energy stored in the entity (heat in furnace, energy stored in electrical devices etc. |
temperature :: double [RW] | The temperature of this entities heat energy source if this entity uses a heat energy source or nil . |
previous_recipe :: LuaRecipe [R] | The previous recipe this furnace was using or nil if the furnace had no previous recipe. |
held_stack :: LuaItemStack [R] | The item stack currently held in an inserter's hand. |
held_stack_position :: Position [R] | Current position of the inserter's "hand". |
train :: LuaTrain [R] | The train this rolling stock belongs to or nil if not rolling stock. |
neighbours :: dictionary[string → array[LuaEntity]] or array[array[LuaEntity]] or LuaEntity [R] | |
belt_neighbours :: dictionary[string → array[LuaEntity]] [R] | The belt connectable neighbours of this belt connectable entity. |
fluidbox :: LuaFluidBox [RW] | Fluidboxes of this entity. |
backer_name :: string [RW] | The backer name assigned to this entity, or nil if this entity doesn't support backer names. |
entity_label :: string [RW] | The label of this entity if it has one or nil . |
time_to_live :: uint [RW] | The ticks left before a ghost, combat robot, highlight box or smoke with trigger is destroyed. |
color :: Color [RW] | The character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner color. |
text :: LocalisedString [RW] | The text of this flying-text entity. |
signal_state :: defines.signal_state [R] | The state of this rail signal. |
chain_signal_state :: defines.chain_signal_state [R] | The state of this chain signal. |
to_be_looted :: boolean [RW] | Will this entity be picked up automatically when the player walks over it? |
crafting_speed :: double [R] | The current crafting speed, including speed bonuses from modules and beacons. |
crafting_progress :: float [RW] | The current crafting progress, as a number in range [0, 1]. |
bonus_progress :: double [RW] | The current productivity bonus progress, as a number in range [0, 1]. |
productivity_bonus :: double [R] | The productivity bonus of this entity. |
pollution_bonus :: double [R] | The pollution bonus of this entity. |
speed_bonus :: double [R] | The speed bonus of this entity. |
consumption_bonus :: double [R] | The consumption bonus of this entity. |
belt_to_ground_type :: string [R] | "input" or "output" , depending on whether this underground belt goes down or up. |
loader_type :: string [RW] | "input" or "output" , depending on whether this loader puts to or gets from a container. |
rocket_parts :: uint [RW] | Number of rocket parts in the silo. |
logistic_network :: LuaLogisticNetwork [RW] | The logistic network this entity is a part of. |
logistic_cell :: LuaLogisticCell [R] | The logistic cell this entity is a part of. |
item_requests :: dictionary[string → uint] [RW] | Items this ghost will request when revived or items this item request proxy is requesting. |
player :: LuaPlayer [R] | The player connected to this character or nil if none. |
unit_group :: LuaUnitGroup [R] | The unit group this unit is a member of, or nil if none. |
damage_dealt :: double [RW] | The damage dealt by this turret, artillery turret, or artillery wagon. |
kills :: uint [RW] | The number of units killed by this turret, artillery turret, or artillery wagon. |
last_user :: LuaPlayer [RW] | The last player that changed any setting on this entity. |
electric_buffer_size :: double [RW] | The buffer size for the electric energy source or nil if the entity doesn't have an electric energy source. |
electric_input_flow_limit :: double [R] | The input flow limit for the electric energy source or nil if the entity doesn't have an electric energy source. |
electric_output_flow_limit :: double [R] | The output flow limit for the electric energy source or nil if the entity doesn't have an electric energy source. |
electric_drain :: double [R] | The electric drain for the electric energy source or nil if the entity doesn't have an electric energy source. |
electric_emissions :: double [R] | The emissions for the electric energy source or nil if the entity doesn't have an electric energy source. |
unit_number :: uint [R] | The unit number or nil if the entity doesn't have one. |
ghost_unit_number :: uint [R] | The unit number of the entity contained in this ghost or nil if the entity doesn't have one. |
mining_progress :: double [RW] | The mining progress for this mining drill or nil if this isn't a mining drill. |
bonus_mining_progress :: double [RW] | The bonus mining progress for this mining drill or nil if this isn't a mining drill. |
power_production :: double [RW] | The power production specific to the ElectricEnergyInterface entity type. |
power_usage :: double [RW] | The power usage specific to the ElectricEnergyInterface entity type. |
bounding_box :: BoundingBox [R] | LuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation. |
secondary_bounding_box :: BoundingBox [R] | The secondary bounding box of this entity or nil if it doesn't have one. |
selection_box :: BoundingBox [R] | LuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation. |
secondary_selection_box :: BoundingBox [R] | The secondary selection box of this entity or nil if it doesn't have one. |
mining_target :: LuaEntity [R] | The mining target or nil if none
|
circuit_connected_entities :: table [R] | Entities that are directly connected to this entity via the circuit network. |
circuit_connection_definitions :: array[CircuitConnectionDefinition] [R] | The connection definition for entities that are directly connected to this entity via the circuit network. |
request_slot_count :: uint [R] | The index of the configured request with the highest index for this entity. |
filter_slot_count :: uint [R] | The number of filter slots this inserter, loader, or logistic storage container has. |
loader_container :: LuaEntity [R] | The container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type. |
grid :: LuaEquipmentGrid [R] | The equipment grid or nil if this entity doesn't have an equipment grid. |
graphics_variation :: uint8 [RW] | The graphics variation for this entity or nil if this entity doesn't use graphics variations. |
tree_color_index :: uint8 [RW] | Index of the tree color. |
tree_color_index_max :: uint8 [R] | Maximum index of the tree colors. |
tree_stage_index :: uint8 [RW] | Index of the tree stage. |
tree_stage_index_max :: uint8 [R] | Maximum index of the tree stages. |
tree_gray_stage_index :: uint8 [RW] | Index of the tree gray stage |
tree_gray_stage_index_max :: uint8 [R] | Maximum index of the tree gray stages. |
burner :: LuaBurner [R] | The burner energy source for this entity or nil if there isn't one. |
shooting_target :: LuaEntity [RW] | The shooting target for this turret or nil . |
proxy_target :: LuaEntity [R] | The target entity for this item-request-proxy or nil
|
stickers :: array[LuaEntity] [R] | The sticker entities attached to this entity or nil if none. |
sticked_to :: LuaEntity [R] | The entity this sticker is sticked to. |
parameters :: ProgrammableSpeakerParameters [RW] | |
alert_parameters :: ProgrammableSpeakerAlertParameters [RW] | |
electric_network_statistics :: LuaFlowStatistics [R] | The electric network statistics for this electric pole. |
inserter_stack_size_override :: uint [RW] | Sets the stack size limit on this inserter. |
products_finished :: uint [RW] | The number of products this machine finished crafting in its lifetime. |
spawner :: LuaEntity [R] | The spawner associated with this unit entity or nil if the unit has no associated spawner. |
units :: array[LuaEntity] [R] | The units associated with this spawner entity. |
power_switch_state :: boolean [RW] | The state of this power switch. |
effects :: ModuleEffects [R] | The effects being applied to this entity or nil . |
infinity_container_filters :: array[InfinityInventoryFilter] [RW] | The filters for this infinity container. |
remove_unfiltered_items :: boolean [RW] | If items not included in this infinity container filters should be removed from the container. |
character_corpse_player_index :: uint [RW] | The player index associated with this character corpse. |
character_corpse_tick_of_death :: uint [RW] | The tick this character corpse died at. |
character_corpse_death_cause :: LocalisedString [RW] | The reason this character corpse character died (if any). |
associated_player :: LuaPlayer [RW] | The player this character is associated with or nil if none. |
tick_of_last_attack :: uint [RW] | The last tick this character entity was attacked. |
tick_of_last_damage :: uint [RW] | The last tick this character entity was damaged. |
splitter_filter :: LuaItemPrototype [RW] | The filter for this splitter or nil if no filter is set. |
inserter_filter_mode :: string [RW] | The filter mode for this filter inserter: "whitelist", "blacklist", or nil if this inserter doesn't use filters. |
splitter_input_priority :: string [RW] | The input priority for this splitter : "left", "none", or "right". |
splitter_output_priority :: string [RW] | The output priority for this splitter : "left", "none", or "right". |
armed :: boolean [R] | If this land mine is armed. |
recipe_locked :: boolean [RW] | When locked; the recipe in this assembling machine can't be changed by the player. |
connected_rail :: LuaEntity [R] | The rail entity this train stop is connected to or nil if there is none. |
trains_in_block :: uint [R] | The number of trains in this rail block for this rail entity. |
timeout :: uint [RW] | The timeout that's left on this landmine in ticks. |
neighbour_bonus :: double [R] | The current total neighbour bonus of this reactor. |
ai_settings :: LuaAISettings [R] | The ai settings of this unit. |
highlight_box_type :: string [RW] | The hightlight box type of this highlight box entity. |
highlight_box_blink_interval :: uint [RW] | The blink interval of this highlight box entity. |
status :: defines.entity_status [R] | The status of this entity or nil if no status. |
enable_logistics_while_moving :: boolean [RW] | If equipment grid logistics are enabled while this vehicle is moving. |
render_player :: LuaPlayer [RW] | The player that this simple-entity-with-owner , simple-entity-with-force , flying-text , or highlight-box is visible to. |
render_to_forces :: array[ForceIdentification] [RW] | The forces that this simple-entity-with-owner , simple-entity-with-force , or flying-text is visible to. |
pump_rail_target :: LuaEntity [R] | The rail target of this pump or nil . |
moving :: boolean [R] | Returns true if this unit is moving. |
electric_network_id :: uint [R] | Returns the id of the electric network that this entity is connected to or nil . |
allow_dispatching_robots :: boolean [RW] | Whether this character's personal roboports are allowed to dispatch robots. |
auto_launch :: boolean [RW] | Whether this rocket silo automatically launches the rocket when cargo is inserted. |
energy_generated_last_tick :: double [R] | How much energy this generator generated in the last tick. |
storage_filter :: LuaItemPrototype [RW] | The storage filter for this logistic storage container. |
request_from_buffers :: boolean [RW] | Whether this requester chest is set to also request from buffer chests. |
corpse_expires :: boolean [RW] | Whether this corpse will ever fade away. |
corpse_immune_to_entity_placement :: boolean [RW] | If true, corpse won't be destroyed when entities are placed over it. |
tags :: Tags [RW] | The tags associated with this entity ghost or nil if not an entity ghost. |
command :: Command [R] | The command given to this unit or nil is the unit has no command. |
distraction_command :: Command [R] | The distraction command given to this unit or nil is the unit currently isn't distracted. |
time_to_next_effect :: uint [RW] | The ticks until the next trigger effect of this smoke-with-trigger. |
autopilot_destination :: Position [RW] | Destination position of spidertron's autopilot. |
autopilot_destinations :: array[Position] [R] | The queued destination positions of spidertron's autopilot. |
trains_count :: uint [R] | Amount of trains related to this particular train stop. |
trains_limit :: uint [RW] | Amount of trains above which no new trains will be sent to this train stop. |
is_entity_with_force :: boolean [R] | If this entity is EntityWithForce |
is_entity_with_owner :: boolean [R] | If this entity is EntityWithOwner |
is_entity_with_health :: boolean [R] | If this entity is EntityWithHealth |
combat_robot_owner :: LuaEntity [RW] | The owner of this combat robot if any. |
link_id :: uint [RW] | The link ID this linked container is using. |
follow_target :: LuaEntity [RW] | The follow target of this spidertron if any. |
follow_offset :: Position [RW] | The follow offset of this spidertron if any. |
linked_belt_type :: string [RW] | Type of linked belt: it is either "input" or "output" . |
linked_belt_neighbour :: LuaEntity [R] | Neighbour to which this linked belt is connected to. |
valid :: boolean [R] | Is this object valid? |
object_name :: string [R] | The class name of this object. |
help() → string | All methods and properties that this object supports. |
Gets the entities output inventory if it has one.
nil
if this entity has
no module inventory. The fuel inventory for this entity or nil
if this entity doesn't have a fuel inventory.
The burnt result inventory for this entity or nil
if this entity doesn't have a burnt result inventory.
Damages the entity.
Checks if the entity can be destroyed
Destroys the entity.
false
.true
, script_raised_destroy will be called. Defaults to false
.false
if the entity was valid and destruction failed, true
in all other cases.Has this unit been assigned a command?
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.
force
is not specified, on_entity_died
will blame the "neutral"
force.cause
argument and no force
:
entity.die(nil, killer_entity)
Test whether this entity's prototype has a flag set.
true
if the entity has the given flag set.entity.has_flag(f)
is a shortcut for entity.prototype.has_flag(f)
.Same as LuaEntity::has_flag but targets the inner entity on a entity ghost.
true
if the entity has the given flag set.Offer a thing on the market.
market.add_market_item{price={{"iron-ore", 10}}, offer={type="give-item", item="copper-ore"}}
market.add_market_item{price={{"iron-ore", 5}, {"stone", 5}}, offer={type="give-item", item="copper-ore"}}
Remove an offer from a market.
true
if the offer was successfully removed; false
when the given index was not valid.Get all offers in a market as an array.
Removes all offers from a market.
Connect two devices with a circuit wire or copper cable. Depending on which type of connection should be made, there are different procedures:
target
must be a LuaEntity that specifies another
electric pole. This will connect them with copper cable.target
must be a table of type
WireConnectionDefinition.
Disconnect circuit wires or copper cables between devices. Depending on which type of connection should be cut, there are different procedures:
target
parameter blank: pole.disconnect_neighbour()
.target
to defines.wire_type.red or
defines.wire_type.green.target
must be a LuaEntity
that specifies the other pole: pole1.disconnect_neighbour(pole2)
.target
must be a table of type WireConnectionDefinition.
Sets the entity to be deconstructed by construction robots.
Cancels deconstruction if it is scheduled, does nothing otherwise.
Is this entity marked for deconstruction?
Sets the entity to be upgraded by construction robots.
Cancels upgrade if it is scheduled, does nothing otherwise.
Is this entity marked for upgrade?
Get a logistic requester slot.
nil
if the given slot contains no request.Set a logistic requester slot.
Clear a logistic requester slot.
Returns whether a craft is currently in process. It does not indicate whether progress is currently being made, but whether any crafting action has made progress in this machine.
true
if this gate is currently opened.
true
if this gate is currently opening.
true
if this gate is currently closed.
true
if this gate is currently closing
Get a transport line of a belt or belt connectable entity.
Get the maximum transport line index of a belt or belt connectable entity.
true
if the rocket was successfully launched. Return value of false
means the silo is not ready for launch.Revive a ghost. I.e. turn it from a ghost to a real entity or tile.
true
the function will return item request proxy as the third parameter.nil
if the ghost could not be revived.nil
as a second return value
and possibly item request proxy as the third parameter depending on value of return_item_request_proxy.Revives a ghost silently.
true
the function will return item request proxy as the third parameter.nil
if the ghost could not be revived.nil
as a second return value
and possibly item request proxy as the third parameter depending on value of return_item_request_proxy.
Get the rails that this signal is connected to.
Get the rail signal or train stop at the start/end of the rail segment this rail is in, or nil
if the rail segment doesn't start/end with a signal nor a train stop.
Get the rail at the end of the rail segment this rail is in.
Get the length of the rail segment this rail is in.
Get a rail from each rail segment that overlaps with this rail's rail segment.
Get the filter for a slot in an inserter, loader, or logistic storage container.
nil
if the given slot has no filter. Gets the filter for this infinity container at the given index or nil
if the filter index doesn't exist or is empty.
Sets the filter for this infinity container at the given index.
Gets the filter for this infinity pipe or nil
if the filter is empty.
Sets the filter for this infinity pipe.
Gets the heat setting for this heat interface.
Sets the heat setting for this heat interface.
Gets the control behavior of the entity (if any).
Gets (and or creates if needed) the control behavior of the entity.
Read a single signal from the combined circuit networks.
The merged circuit network signals or nil
if there are no signals.
Whether this entity supports a backer name.
Copies settings from the given entity onto this entity.
Gets all the LuaLogisticPoint
s that this entity owns. Optionally returns only the point specified by the index parameter.
LuaLogisticPoint
specified by this index.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.Connects the rolling stock in the given direction.
Tries to disconnect this rolling stock in the given direction.
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 loose performance by checking this in normal games.
Current recipe being assembled by this machine or nil
if no recipe is set.
Rotates this entity as if the player rotated it.
true
, rotate the entity in the counter-clockwise direction.Gets the driver of this vehicle if any.
nil
if the vehicle contains no driver. To check if there's a passenger see LuaEntity::get_passenger.Sets the driver of this vehicle.
nil
to eject the current driver if any.Gets the passenger of this car or spidertron if any.
nil
if the vehicle contains no passenger. To check if there's a driver see LuaEntity::get_driver.Sets the passenger of this car or spidertron.
Returns true if this entity is connected to an electric network.
The trains scheduled to stop at this train stop.
The train currently stopped at this train stop or nil
if none.
Clones this entity.
nil
if this entity can't be cloned/can't be cloned to the given location.Get the amount of all or some fluid in this entity.
Get amounts of all fluids in this entity.
Remove fluid from this entity.
Insert fluid into this entity. Fluidbox is chosen automatically.
Remove all fluids from this entity.
Get the source of this beam.
Get the target of this beam.
The radius of this entity.
The health ratio of this entity between 1 and 0 (for full health and no health respectively).
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 the unit from the spawner which spawned it. This allows the spawner to continue spawning additional units.
Toggle this entity's equipment movement bonus. Does nothing if the entity does not have an equipment grid.
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.
Returns the new entity prototype.
Returns the new entity direction after upgrading.
Returns the amount of damage to be taken by this entity.
Depletes and destroys this resource entity.
Mines this entity.
Triggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or "unit-spawner".
Gets rolling stock connected to the given end of this stock
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 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. This is worst-case O(N) complexity where N is the current number of things in the deconstruct queue.
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 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.
Adds the given position to this spidertron's autopilot's queue of destinations.
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.
Disconnects linked belt from its neighbour.
Name of the entity prototype. E.g. "inserter" or "filter-inserter".
Name of the entity or tile contained in this ghost
Localised name of the entity.
Localised name of the entity or tile contained in this ghost.
The entity prototype type of this entity.
The prototype type of the entity or tile contained in this ghost.
Deactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will stop moving etc).
When the entity is not destructible it can't be damaged.
When entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key.
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.
The current health of the entity, or nil
if it doesn't have health. Health is automatically clamped to be between
0
and max health (inclusive). Entities with a health of 0
can not be attacked.
The current direction this entity is facing.
Whether the entity has direction. When it is false for this entity, it will always return north direction when asked for.
The smooth orientation of this entity, if it supports orientation.
The orientation of this cliff.
The relative orientation of the vehicle turret, artillery turret, artillery wagon
or nil
if this entity isn't a vehicle with a vehicle turret or artillery turret/wagon.
The torso orientation of this spider vehicle.
Count of resource units contained.
Count of initial resource units contained.
nil
and writing will give an error. Multiplies the acceleration the vehicle can create for one unit of energy. By default
is 1
.
Multiplies the energy consumption.
Multiplies the car friction rate.
game.player.vehicle.friction_modifier = 0.5
Whether the driver of this car or spidertron is the gunner, if false, the passenger is the gunner.
Read when this spidertron auto-targets enemies
The current speed of this car in tiles per tick, rolling stock, projectile or spider vehicle, or current max speed of the unit. Only the speed of units, cars, and projectiles are writable.
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 entity prototype of this entity.
The prototype of the entity or tile contained in this ghost.
Position where the entity puts its stuff.
allow_custom_vectors
set to true on their prototype to allow changing the drop position.Where the inserter will pick up items from.
allow_custom_vectors
set to true on their prototype to allow changing the pickup position. The entity this entity is putting its stuff to or nil
if there is no such entity.
The entity the inserter will attempt to pick up from. For example, this can be a transport belt or a storage chest.
Index of the currently selected weapon slot of this character, car, or spidertron, or nil
if the car/spidertron doesn't have guns.
Energy stored in the entity (heat in furnace, energy stored in electrical devices etc.). always 0 for entities that don't have the concept of energy stored inside.
game.player.print("Machine energy: " .. game.player.selected.energy .. "J")
game.player.selected.energy = 3000
The temperature of this entities heat energy source if this entity uses a heat energy source or nil
.
The previous recipe this furnace was using or nil if the furnace had no previous recipe.
The item stack currently held in an inserter's hand.
Current position of the inserter's "hand".
The train this rolling stock belongs to or nil if not rolling stock.
"copper"
, "red"
, and "green"
.nil
if none. 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.
This is a dictionary with "inputs"
, "outputs"
entries that are arrays of transport belt connectable entities, or empty tables if no entities.
Fluidboxes of this entity.
The backer name assigned to this entity, or nil
if this entity doesn't support backer names.
Entities that support backer names are labs, locomotives, radars, roboports, and train stops.
backer_name
returns the player-given name of the entity. The label of this entity if it has one or nil
. Changing the value will trigger on_entity_renamed event
The ticks left before a ghost, combat robot, highlight box or smoke with trigger is destroyed.
The character, rolling stock, train stop, car, spider-vehicle, flying text, corpse or simple-entity-with-owner color. Returns nil
if this entity doesn't use custom colors.
The text of this flying-text entity.
The state of this rail signal.
The state of this chain signal.
Will this entity be picked up automatically when the player walks over it?
The current crafting speed, including speed bonuses from modules and beacons.
The current crafting progress, as a number in range [0, 1].
The current productivity bonus progress, as a number in range [0, 1].
The productivity bonus of this entity.
The pollution bonus of this entity.
The speed bonus of this entity.
The consumption bonus of this entity.
"input"
or "output"
, depending on whether this underground belt goes down or up.
"input"
or "output"
, depending on whether this loader puts to or gets from a container.
Number of rocket parts in the silo.
The logistic network this entity is a part of.
The logistic cell this entity is a part of. Will be nil
if this entity is not a part of any logistic cell.
Items this ghost will request when revived or items this item request proxy is requesting. Result is a dictionary mapping each item prototype name to the required count.
The player connected to this character or nil
if none.
The unit group this unit is a member of, or nil
if none.
The damage dealt by this turret, artillery turret, or artillery wagon.
The number of units killed by this turret, artillery turret, or artillery wagon.
The last player that changed any setting on this entity. This includes building the entity, changing its color,
or configuring its circuit network. Can be nil
if the last user is not part of the save anymore. Mods can
overwrite it if desired.
The buffer size for the electric energy source or nil if the entity doesn't have an electric energy source.
The input flow limit for the electric energy source or nil if the entity doesn't have an electric energy source.
The output flow limit for the electric energy source or nil if the entity doesn't have an electric energy source.
The electric drain for the electric energy source or nil if the entity doesn't have an electric energy source.
The emissions for the electric energy source or nil if the entity doesn't have an electric energy source.
The unit number or nil if the entity doesn't have one. This is universally unique for every entity that has one, for the lifetime of a whole game.
The unit number of the entity contained in this ghost or nil if the entity doesn't have one.
The mining progress for this mining drill or nil
if this isn't a mining drill. Is a number in range [0, mining_target.prototype.mineable_properties.mining_time]
The bonus mining progress for this mining drill or nil
if this isn't a mining drill. Read yields a number in range [0, mining_target.prototype.mineable_properties.mining_time]
The power production specific to the ElectricEnergyInterface entity type.
The power usage specific to the ElectricEnergyInterface entity type.
LuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation.
The secondary bounding box of this entity or nil
if it doesn't have one.
LuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation.
The secondary selection box of this entity or nil
if it doesn't have one.
The mining target or nil
if none
The connection definition for entities that are directly connected to this entity via the circuit network.
The index of the configured request with the highest index for this entity. This means 0 if no requests are set and e.g. 20 if the 20th request slot is configured.
The number of filter slots this inserter, loader, or logistic storage container has. 0 if not one of those entities.
The container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type.
The equipment grid or nil
if this entity doesn't have an equipment grid.
The graphics variation for this entity or nil
if this entity doesn't use graphics variations.
Index of the tree color.
Maximum index of the tree colors.
Index of the tree stage.
Maximum index of the tree stages.
Index of the tree gray stage
Maximum index of the tree gray stages.
The burner energy source for this entity or nil
if there isn't one.
The shooting target for this turret or nil
.
The target entity for this item-request-proxy or nil
The sticker entities attached to this entity or nil
if none.
The entity this sticker is sticked to.
The electric network statistics for this electric pole.
Sets the stack size limit on this inserter. If the stack size is > than the force stack size limit the value is ignored.
The number of products this machine finished crafting in its lifetime.
The spawner associated with this unit entity or nil
if the unit has no associated spawner.
The units associated with this spawner entity.
The state of this power switch.
The effects being applied to this entity or nil
. For beacons this is the effect the beacon is broadcasting.
The filters for this infinity container.
If items not included in this infinity container filters should be removed from the container.
The player index associated with this character corpse.
The tick this character corpse died at.
The reason this character corpse character died (if any).
The player this character is associated with or nil
if none.
When the player logs off in multiplayer all of the associated characters will be logged off with him.
nil
to clear. The player will be automatically disassociated when a controller is set on the character.The last tick this character entity was attacked.
The last tick this character entity was damaged.
The filter for this splitter or nil
if no filter is set.
The filter mode for this filter inserter: "whitelist", "blacklist", or nil
if this inserter doesn't use filters.
The input priority for this splitter : "left", "none", or "right".
The output priority for this splitter : "left", "none", or "right".
If this land mine is armed.
When locked; the recipe in this assembling machine can't be changed by the player.
The rail entity this train stop is connected to or nil
if there is none.
The number of trains in this rail block for this rail entity.
The timeout that's left on this landmine in ticks. It describes the time between the landmine being placed and it being armed.
The current total neighbour bonus of this reactor.
The ai settings of this unit.
The hightlight box type of this highlight box entity.
The blink interval of this highlight box entity. 0 indicates no blink.
The status of this entity or nil
if no status.
If equipment grid logistics are enabled while this vehicle is moving.
The player that this simple-entity-with-owner
, simple-entity-with-force
, flying-text
, or highlight-box
is visible to.
nil
means it is rendered for every player.
The forces that this simple-entity-with-owner
, simple-entity-with-force
, or flying-text
is visible to.
nil
or an empty array means it is rendered for every force.
The rail target of this pump or nil
.
Returns true if this unit is moving.
Returns the id of the electric network that this entity is connected to or nil
.
Whether this character's personal roboports are allowed to dispatch robots.
Whether this rocket silo automatically launches the rocket when cargo is inserted.
How much energy this generator generated in the last tick.
The storage filter for this logistic storage container.
Whether this requester chest is set to also request from buffer chests.
Whether this corpse will ever fade away.
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.
The tags associated with this entity ghost or nil
if not an entity ghost.
The command given to this unit or nil
is the unit has no command.
The distraction command given to this unit or nil
is the unit currently isn't distracted.
The ticks until the next trigger effect of this smoke-with-trigger.
Destination position of spidertron's autopilot. Returns nil
if autopilot doesn't have destination set.
The queued destination positions of spidertron's autopilot.
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. Writing nil will disable the limit (will set a maximum possible value).
Amount of trains above which no new trains will be sent to this train stop.
If this entity is EntityWithForce
If this entity is EntityWithOwner
If this entity is EntityWithHealth
The owner of this combat robot if any.
The link ID this linked container is using.
The follow target of this spidertron if any.
The follow offset of this spidertron if any. If it is not following an entity this will be nil. This is randomized each time the follow entity is set.
Type of linked belt: it is either "input"
or "output"
. Changing type will also flip direction so the belt is out of the same side
Neighbour to which this linked belt is connected to. Returns nil if not connected.