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) → float | Damages the entity. |
can_be_destroyed() → boolean | Checks if the entity can be destroyed |
destroy(do_cliff_correction) → boolean | Destroys the entity. |
set_command(command) | Give the entity a 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. |
add_market_item{price=…, offer=…} | Offer a thing on the market. |
remove_market_item(offer) → boolean | Remove an offer from a market. |
get_market_items() → array of Offer | Get all offers in a market as an array. |
connect_neighbour(target) | Connect two devices with wire or cable. |
disconnect_neighbour(target) | Disconnect wires or cables. |
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(force) → boolean | Is this entity marked for deconstruction? |
get_request_slot(slot) → SimpleItemStack | Get a logistic requester slot. |
set_request_slot(request, slot) | Set a logistic requester slot. |
clear_request_slot(slot) | Clear a logistic requester slot. |
is_crafting() → boolean | |
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. |
launch_rocket() → boolean | |
revive(return_item_request_proxy) → dictionary string → uint | Revive a ghost. |
get_connected_rail{rail_direction=…, rail_connection_direction=…} → LuaEntity | |
get_filter(uint) → string | Get the filter for a slot in an inserter or a loader. |
set_filter(uint, string) | Set the filter for a slot in an inserter or a loader |
get_infinity_filter(index) → InfinityFilter | 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_filter(index, filter) | Sets the filter for this infinity container at the given index. |
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_signals(circuit_connector) | The merged circuit network signals or nil if there are no signals. |
supports_backer_name() → boolean | |
copy_settings(entity) → dictionary string → uint | Copies settings from the given entity onto this entity. |
get_logistic_point(defines.logistic_member_index) → LuaLogisticPoint or array of LuaLogisticPoint | Gets the LuaLogisticPoint specified by the given index or if not given returns all of the points 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 and beacon connections to entities that might have been teleported out or in by the script. |
get_recipe() | Current recipe being assembled by this machine. |
set_recipe(recipe) → dictionary string → uint | Sets the current recipe in this assembly machine. |
rotate(options) → 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 if any. |
set_passenger(passenger) | Sets the passenger of this car. |
is_connected_to_electric_network() → boolean | Returns true if this entity is connected to an electric network. |
get_train_stop_trains() | The trains scheduled to stop at this train stop. |
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] | Health of the entity. |
direction :: defines.direction [RW] | The current direction this entity is facing. |
supports_direction :: boolean [R] | Whether the entity has direction. |
orientation :: float [RW] | The smooth orientation. |
cliff_orientation :: string [R] | The orientation of this cliff. |
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. |
speed :: float [RW] | The current speed of the car or rolling stock. |
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 [R] | The entity this entity is putting its stuff to or nil if there is no such entity. |
pickup_target :: LuaEntity [R] | 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. |
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 of LuaEntity or array of array of LuaEntity or LuaEntity [R] | |
fluidbox :: LuaFluidBox [RW] | |
backer_name :: string [RW] | The name of a backer (of Factorio) assigned to a lab or train station / stop. |
time_to_live :: uint [RW] | The ticks left before a ghost or combat robot is destroyed. |
color :: Color [RW] | The character or rolling stock 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 :: uint [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_progress :: float [RW] | The current crafting progress, as a number in range [0, 1]. |
bonus_progress :: float [RW] | The current productivity bonus progress, as a number in range [0, 1]. |
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 [R] | 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 player who built the 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 size 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. |
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] | |
secondary_bounding_box :: BoundingBox [R] | The secondary bounding box of this entity or nil if it doesn't have one. |
selection_box :: BoundingBox [R] | |
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 [R] | Entities connected to this entity via the circuit network. |
circuit_connection_definitions :: array of CircuitConnectionDefinition [R] | The connection definition for entities connected to this entity via the circuit network. |
request_slot_count :: uint [R] | The number of request slots this entity has. |
filter_slot_count :: uint [R] | The number of filter slots this inserter or loader has. |
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 |
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 of LuaEntity [R] | The sticker entities attached to this entity. |
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] | |
spawner :: LuaEntity [R] | The spawner associated with this unit entity or nil if the unit has no associated spawner. |
units :: array of LuaEntity [R] | The units associated with this spawner entity. |
power_switch_state :: boolean [RW] | The state of this power switch. |
relative_turret_orientation :: float [RW] | The relative orientation of the vehicle turret or nil if this entity isn't a vehicle or have a vehicle turret. |
effects :: Effects [R] | The effects being applied to this entity or nil . |
infinity_filters :: array of InfinityFilter [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 [R] | The last tick this character entity was attacked. |
tick_of_last_damage :: uint [R] | The last tick this character entity was damaged. |
splitter_filter :: LuaItemPrototype [RW] | The filter for this splitter or nil if no filter is set. |
splitter_input_priority :: string [RW] | The input priority for this splitter: "left", "none", or "right". |
splitter_output_priority :: string [RW] | The input priority for this splitter: "left", "none", or "right". |
armed :: boolean [R] | If this land mine is armed. |
valid :: boolean [R] | Is this object valid? |
help() → string | All methods, and properties that this object supports. |
The primary interface for interacting with entities through the Lua API. Entity is everything on the map except tiles.
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.
Has this unit been assigned a command?
Immediately kills the entity. Doesn't care whether the entity is destroyable or damageable. Does nothing if the entity doesn't have health. Unlike LuaEntity::destroy, die will trigger on_entity_died and the entity will drop loot and corpse if it have any.
nil
for force if you just want to provide the cause 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)
.Offer a thing on the market.
"give-item"
modifier. 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.
Connect two devices with wire or cable.
Disconnect wires or cables.
pole.disconnect_neighbour()
pole1.disconnect_neighbour(pole2)
.Sets the entity to be deconstructed by construction robots.
Cancels deconstruction if it is scheduled, does nothing otherwise.
Get a logistic requester slot.
nil
if the given slot contains no request.Set a logistic requester slot.
Clear a logistic requester slot.
true
if this machine is currently crafting.
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 closingGet a transport line of a belt.
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.
Get the filter for a slot in an inserter or a loader.
nil
if the given slot
has no filter.Set the filter for a slot in an inserter or a loader
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 control behavior of the entity (if any).
Gets (and or creates if needed) the control behavior of the entity.
The merged circuit network signals or nil
if there are no signals.
true
if this entity supports a backer name.Copies settings from the given entity onto this entity.
Gets the LuaLogisticPoint specified by the given index or if not given returns all of the points this entity owns.
Connects the rolling stock in the given direction.
Tries to disconnect this rolling stock in the given direction.
Reconnect loader and beacon 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.
Rotates this entity as if the player rotated it
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.
Gets the passenger of this car 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.
Returns true if this entity is connected to an electric network.
The trains scheduled to stop at this train stop.
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.
Health of the entity. Setting health to less than 0 will set health to 0, entities with 0 health can not be attacked. Setting health to higher than max health will set health to max health.
nil
.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.
The orientation of this cliff.
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
The current speed of the car or rolling stock.
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.
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 name of a backer (of Factorio) assigned to a lab or train station / stop.
nil
when the entity doesn't support a backer name.The ticks left before a ghost or combat robot is destroyed.
The character or rolling stock color.
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 progress, as a number in range [0, 1].
The current productivity bonus progress, as a number in range [0, 1].
"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 player who built the entity
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 size 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 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.
The secondary bounding 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.
The mining target or nil
if none
The connection definition for entities connected to this entity via the circuit network.
Each CircuitConnectionDefinition is a table:
The number of request slots this entity has.
The number of filter slots this inserter or loader has. 0 if not an inserter or loader.
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
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.
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 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 relative orientation of the vehicle turret or nil
if this entity isn't a vehicle or have a vehicle turret.
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 input priority for this splitter: "left", "none", or "right".
The input priority for this splitter: "left", "none", or "right".
If this land mine is armed.