get_output_inventory() → LuaInventory | Gets the entities output inventory if it has one. |
get_module_inventory() → LuaInventory | |
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) | Sets the entity to be deconstructed by construction robots. |
cancel_deconstruction(force) | Cancels deconstruction if it is scheduled, does nothing otherwise. |
to_be_deconstructed() → boolean | Is this entity marked for deconstruction? |
get_filter(slot) → string | Get the filter for a slot. |
set_filter(filter, slot) | Set the filter for a slot. |
clear_filter(slot) | Clear the filter for a slot. |
get_request_slot(slot) → LuaItemStack | Get a logistic requester slot. |
set_request_slot(request, slot) | Set a logistic requester slot. |
clear_request_slot(slot) | Clear a logistic requester slot. |
get_circuit_condition(connector) → CircuitCondition | |
set_circuit_condition(connector, condition) | |
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() → uint | Revive a ghost. |
get_connected_rail{rail_direction=…, rail_connection_direction=…} → LuaEntity | |
get_inventory(inventory) → LuaInventory | Get an inventory belonging to this entity. |
can_insert(items) → boolean | Can at least some items be inserted? |
insert(items) → uint | Insert items into this entity. |
get_item_count(item) → uint | Get the number of all or some items in this entity. |
has_items_inside() → boolean | Does this entity have any item inside it? |
clear_items_inside() | Remove all items from this entity. |
remove_item(items) → uint | Remove items from this entity. |
teleport(position, surface) → boolean | Teleport the entity to a given position, possibly on another surface. |
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 contained in this ghost |
localised_name :: string [R] | Localised name of the entity. |
ghost_localised_name :: string [R] | Localised name of the entity contained in this ghost. |
type :: string [R] | The entity prototype type of this entity. |
ghost_type :: string [R] | The prototype type of the entity 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. |
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 [R] | The entity prototype of the entity contained in this ghost. |
drop_position :: Position [R] | Position where the entity puts its stuff. |
drop_target :: LuaEntity [R] | The entity this entity is putting its stuff to or nil if there is no such entity. |
selected_gun_index :: uint [RW] | Index of the currently selected weapon slot of this character. |
energy :: float [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. |
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 entity before it's destroyed. |
color :: Color [RW] | The character's color. |
signal_state :: 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 [R] | The current crafting progress, as a number in range [0, 1]. |
bonus_progress :: float [R] | 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. |
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. |
force :: string or LuaForce [RW] | The force of this entity. |
surface :: LuaSurface [R] | The surface this entity is currently on. |
position :: Position [R] | Current position of the entity. |
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.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)
.Is this entity marked for deconstruction?
Get the filter for a slot.
nil
if the given slot
has no filter.Set the filter for a slot.
entity.set_filter("iron-plate", 2)
Clear the filter for a slot.
entity.clear_filter(2)
Get a logistic requester slot.
nil
if the given slot contains no request.Set a logistic requester slot.
Clear a logistic requester slot.
nil
if no condition is set. local currentCondition = inserter.get_circuit_condition(defines.circuitconditionindex.inserter_circuit)
currentCondition.count = currentCondition.count + 10
inserter.set_circuit_condition(defines.circuitconditionindex.inserter_circuit, currentCondition)
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.
nil
if the
ghost could not be revived.
Get an inventory belonging to this entity. This can be either the "main" inventory or some auxiliary one, like the module slots or logistic trash slots.
Can at least some items be inserted?
true
if at least a part of the given items could be inserted into this inventory.Insert items into this entity. This works the same way as inserters or shift-clicking: the "best" inventory is chosen automatically.
Get the number of all or some items in this entity.
Does this entity have any item inside it?
Remove all items from this entity.
Remove items from this entity.
Teleport the entity to a given position, possibly on another surface.
true
when the entity was successfully teleported.false
when used
on any such 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 "smart-inserter".
Name of the entity contained in this ghost
Localised name of the entity.
Localised name of the entity contained in this ghost.
The entity prototype type of this entity.
The prototype type of the entity 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.
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 entity prototype of the entity contained in this ghost.
Position where the entity puts its stuff.
The entity this entity is putting its stuff to or nil
if there is no such entity.
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.
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.
The ticks left for a ghost entity before it's destroyed. Cannot be set higher than LuaForce::ghost_time_to_live of the entity's force.
The character's 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.
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.
The surface this entity is currently on.
Current position of the entity.