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. |
damage(damage, force, type) → float | Damages the entity. |
destroy() → boolean | Destroys the entity. |
set_command(command) | Give the entity a command. |
has_command() → boolean | Has this unit been assigned a command? |
die() | 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) → boolean | Sets the entity to be deconstructed by construction robots. |
cancel_deconstruction(force) | 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() → 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_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 | |
supports_backer_name() → boolean | |
copy_settings(entity) → dictionary string → uint | Copies settings from the given entity onto this entity. |
passenger :: LuaEntity [RW] | Setting to nil forces the character out of the vehicle, setting to a new character
forces any existing passenger out and the given character becomes the new passenger. |
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. |
ghost_localised_name :: LocalisedString [R] | Localised name of the entity or tile contained in this ghost. |
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. |
amount :: uint [RW] | Count of 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 the energy consumption. |
friction_modifier :: float [RW] | Multiplies the car friction rate. |
speed :: float [RW] | The current speed of the car. |
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. |
recipe :: LuaRecipe [RW] | Current recipe being assembled by this machine. |
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. |
neighbours :: dictionary string → array of LuaEntity or 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 for a ghost before it's destroyed. |
color :: Color [RW] | The character or rolling stock color. |
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 [R] | "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. |
player :: LuaPlayer [R] | The player connected to this character. |
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. |
kills :: uint [RW] | The number of units killed by this turret. |
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 [RW] | 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 [RW] | The output flow limit for the electric energy source or nil if the entity doesn't have an electric energy source. |
electric_drain :: double [RW] | The electric drain for the electric energy source or nil if the entity doesn't have an electric energy source. |
electric_emissions :: double [RW] | 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] | |
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. |
valid :: boolean [R] | Is this object valid? |
Inherited from LuaControl: get_inventory, get_quickbar, can_insert, insert, set_gui_arrow, clear_gui_arrow, get_item_count, has_items_inside, can_reach_entity, clear_items_inside, remove_item, teleport, update_selected_entity, clear_selected_entity, disable_flashlight, enable_flashlight, get_craftable_count, begin_crafting, cancel_crafting, surface, position, vehicle, force, selected, opened, crafting_queue_size, walking_state, riding_state, mining_state, cursor_stack, driving, crafting_queue, cheat_mode, character_crafting_speed_modifier, character_mining_speed_modifier, character_running_speed_modifier, character_build_distance_bonus, character_item_drop_distance_bonus, character_reach_distance_bonus, character_resource_reach_distance_bonus, character_item_pickup_distance_bonus, character_loot_pickup_distance_bonus, quickbar_count_bonus, character_inventory_slots_bonus, character_logistic_slot_count_bonus, character_trash_slot_count_bonus, character_maximum_following_robot_count_bonus, character_health_bonus, auto_trash_filters |
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.
Damages the entity.
Destroys the entity.
Has this unit been assigned a command?
Immediately kills the entity. Doesn't attribute the kill to any force. Doesn't care whether the entity is destroyable or damageable. Error is thrown when called on entity that 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.
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)
.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.
nil
if the ghost could not be revived.nil
as a second return value.
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 control behavior of the entity (if any).
Gets (and or creates if needed) the control behavior of the entity.
true
if this entity supports a backer name.Copies settings from the given entity onto this entity.
Setting to nil
forces the character out of the vehicle, setting to a new character
forces any existing passenger out and the given character becomes the new passenger.
nil
if the car contains no passenger.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.
Count of resource units contained.
Multiplies the acceleration the vehicle can create for one unit of energy. By default
is 1
.
Multiplies the the energy consumption.
Multiplies the car friction rate.
game.player.vehicle.friction_modifier = 0.5
The current speed of the car.
The entity prototype of this entity.
The prototype of the entity or tile contained in this ghost.
Position where the entity puts its stuff.
Where the inserter will pick up items from.
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
Current recipe being assembled by this machine.
The item stack currently held in an inserter's hand.
Current position of the inserter's "hand".
The train this rolling stock belongs to.
"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 for a ghost before it's destroyed. Cannot be set higher than LuaForce::ghost_time_to_live of the entity's force.
The character or rolling stock color.
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. Result is a dictionary mapping each item prototype name to the required count.
The player connected to this character.
The unit group this unit is a member of, or nil
if none.
The damage dealt by this turret.
The number of units killed by this turret.
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 unique for every entity that has one.
The mining progress for this mining drill or nil
if this isn't a mining drill.
The bonus mining progress for this mining drill or nil
if this isn't a mining drill.
The power production specific to the ElectricEnergyInterface entity type.
The power usage specific to the ElectricEnergyInterface entity type.
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.