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.
LuaControldoubleunknownfalseLength of this rail piece.
stringunknownfalseName of the entity prototype. E.g. "inserter" or "fast-inserter".
stringunknownfalseName of the entity or tile contained in this ghost.
LocalisedStringunknownfalseLocalised name of the entity.
LocalisedStringunknownfalseLocalisedStringunknownfalseLocalised name of the entity or tile contained in this ghost.
LocalisedStringunknownfalsestringunknownfalseThe entity prototype type of this entity.
stringunknownfalseThe prototype type of the entity or tile contained in this ghost.
booleanbooleanfalseIf set to 'true', this inserter will use filtering logic.
This has no effect if the prototype does not support filters.
booleanbooleanfalseDeactivating an entity will stop all its operations (car will stop moving, inserters will stop working, fish will stop moving etc).
Reading from this returns false if the entity is deactivated in at least one of the following ways: by script, by circuit network, by recipe, by freezing, or by deconstruction.
Writing to this is deprecated and affects only the disabled_by_script state.
Entities that are not active naturally can't be set to be active (setting it to be active will do nothing). Some entities (Corpse, FireFlame, Roboport, RollingStock, dying entities) need to remain active and will ignore writes.
booleanbooleanfalseIf set to false, this entity can't be damaged and won't be attacked automatically. It can however still be mined.
Entities that are indestructible naturally (they have no health, like smoke, resource etc) can't be set to be destructible.
booleanbooleanfalseNot minable entities can still be destroyed.
Tells if entity reports as being minable right now. This takes into account minable_flag and entity specific conditions (for example rail under rolling stocks is not minable, vehicle with passenger is not minable).
Write to this field since 2.0.26 is deprecated and it will result in write to minable_flag instead.
booleanbooleanfalseScript controlled flag that allows entity to be mined.
booleanbooleanfalseWhen entity is not to be rotatable (inserter, transport belt etc), it can't be rotated by player using the R key.
Entities that are not rotatable naturally (like chest or furnace) can't be set to be rotatable.
booleanbooleanfalsePlayer can't open gui of this entity and he can't quick insert/input stuff in to the entity when it is not operable.
floatfloattrueThe current health of the entity, if any. Health is automatically clamped to be between 0 and max health (inclusive). Entities with a health of 0 can not be attacked.
To get the maximum possible health of this entity, see LuaEntity::max_health.
floatunknownfalseMax health of this entity.
defines.directiondefines.directionfalseThe current direction this entity is facing.
booleanbooleanfalseWhether the entity is currently mirrored. This state is referred to as flipped elsewhere, such as on the on_player_flipped_entity event.
If an entity is mirrored, it is flipped over the axis that is pointing in the entity's direction. For example if a mirrored entity is facing north, everything that was defined to be facing east in the prototype now faces west.
booleanunknownfalseWhether the entity has direction. When it is false for this entity, it will always return north direction when asked for.
RealOrientationRealOrientationfalseThe smooth orientation of this entity. For turrets this is the orientation of the weapon.
CliffOrientationunknownfalseThe orientation of this cliff.
RealOrientationRealOrientationtrueThe relative orientation of the vehicle turret, artillery turret, artillery wagon. nil if this entity isn't a vehicle with a vehicle turret or artillery turret/wagon.
Writing does nothing if the vehicle doesn't have a turret.
For the turret orientation of non-artillery turrets, use LuaEntity::orientation.
RealOrientationRealOrientationfalseThe torso orientation of this spider vehicle.
uint32uint32falseCount of resource units contained.
uint32uint32trueCount of initial resource units contained. nil if this is not an infinite resource.
If this is not an infinite resource, writing will produce an error.
floatfloatfalseMultiplies the acceleration the car can create for one unit of energy. Defaults to 1.
floatfloatfalseMultiplies the energy consumption.
floatfloatfalseMultiplies the car friction rate.
booleanbooleantrueWhether the driver of this car or spidertron is the gunner. If false, the passenger is the gunner. nil if this is neither a car or a spidertron.
VehicleAutomaticTargetingParametersVehicleAutomaticTargetingParametersfalseRead when this spidertron auto-targets enemies
floatfloattrueThe current speed if this is a car, rolling stock, projectile or spidertron, or the maximum speed if this is a unit. The speed is in tiles per tick. nil if this is not a car, rolling stock, unit, projectile or spidertron.
Only the speed of units, cars, and projectiles are writable.
floatunknowntrueThe current speed of this unit in tiles per tick, taking into account any walking speed modifier given by the tile the unit is standing on. nil if this is not a unit.
LuaItemStackunknownfalseLuaEntityPrototypeunknownfalseThe entity prototype of this entity.
LuaEntityPrototype | LuaTilePrototypeunknownfalseThe prototype of the entity or tile contained in this ghost.
MapPositionMapPositionfalsePosition where the entity puts its stuff.
Mining drills and crafting machines can't have their drop position changed; inserters must have allow_custom_vectors set to true on their prototype to allow changing the drop position.
Meaningful only for entities that put stuff somewhere, such as mining drills, crafting machines with a drop target or inserters.
MapPositionMapPositionfalseWhere the inserter will pick up items from.
Inserters must have allow_custom_vectors set to true on their prototype to allow changing the pickup position.
LuaEntityLuaEntitytrueThe entity this entity is putting its items to. If there are multiple possible entities at the drop-off point, writing to this attribute allows a mod to choose which one to drop off items to. The entity needs to collide with the tile box under the drop-off position. nil if there is no entity to put items to, or if this is not an entity that puts items somewhere.
LuaEntityLuaEntitytrueThe entity this inserter will attempt to pick up items from. If there are multiple possible entities at the pick-up point, writing to this attribute allows a mod to choose which one to pick up items from. The entity needs to collide with the tile box under the pick-up position. nil if there is no entity to pull items from.
uint32uint32trueIndex of the currently selected weapon slot of this character, car, or spidertron. nil if this entity doesn't have guns.
doubledoublefalseEnergy stored in the entity's energy buffer (energy stored in electrical devices etc.). Always 0 for entities that don't have the concept of energy stored inside.
doubledoubletrueThe temperature of this entity's heat energy source. nil if this entity does not use a heat energy source.
RecipeIDAndQualityIDPairunknowntrueThe previous recipe this furnace was using, if any.
LuaItemStackunknownfalseThe item stack currently held in an inserter's hand.
MapPositionunknownfalseCurrent position of the inserter's "hand".
LuaTrainunknowntrueThe train this rolling stock belongs to, if any. nil if this is not a rolling stock.
Dict<string, Array<LuaEntity>> | Array<Array<LuaEntity>> | LuaEntityunknowntrueA list of neighbours for certain types of entities. Applies to underground belts, walls, gates, reactors, heat pipes, cliffs, and pipe-connectable entities.
{ inputs: Array<LuaEntity>, outputs: Array<LuaEntity> }unknownfalseThe 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.
Array<LuaEntity>unknownfalseThe entities connected to this entities heat buffer.
LuaFluidBoxunknownfalseFluidboxes of this entity.
stringstringtrueThe backer name assigned to this entity. Entities that support backer names are labs, locomotives, radars, roboports, and train stops. nil if this entity doesn't support backer names.
While train stops get the name of a backer when placed down, players can rename them if they want to. In this case, backer_name returns the player-given name of the entity.
stringstringtrueThe label on this spider-vehicle entity, if any. nil if this is not a spider-vehicle.
uint64uint64falseThe ticks left before a combat robot, highlight box, smoke, or sticker entity is destroyed.
ColorColortrueThe color of this character, rolling stock, corpse, character corpse, train stop, simple-entity-with-owner, car, spider-vehicle, or lamp. nil if this entity doesn't use custom colors.
Car color is overridden by the color of the current driver/passenger, if there is one.
defines.signal_stateunknownfalseThe state of this rail signal.
defines.chain_signal_stateunknownfalseThe state of this chain signal.
booleanbooleanfalseWill this item entity be picked up automatically when the player walks over it?
doubleunknownfalseThe current crafting speed, including speed bonuses from modules and beacons.
floatfloatfalseThe current crafting progress, as a number in range [0, 1].
doubledoublefalseThe current productivity bonus progress, as a number in range [0, 1].
LuaQualityPrototypeQualityIDtrueThe quality produced when this crafting machine finishes crafting. nil when crafting is not in progress.
Note: Writing nil is not allowed.
doubleunknownfalseThe productivity bonus of this entity.
This includes force based bonuses as well as beacon/module bonuses.
doubleunknownfalseThe pollution bonus of this entity.
doubleunknownfalseThe speed bonus of this entity.
This includes force based bonuses as well as beacon/module bonuses.
doubleunknownfalseThe consumption bonus of this entity.
BeltConnectionTypeunknownfalseWhether this underground belt goes into or out of the ground.
BeltConnectionTypeBeltConnectionTypefalseWhether this loader gets items from or puts item into a container.
booleanbooleanfalseWhen true, the rocket silo will automatically request items for space platforms in orbit.
Setting the value will have no effect when the silo doesn't support logistics.
LuaSpacePlatformunknowntrueThe space platform in orbit this rocket silo is automatically requesting items for.
uint32uint32falseNumber of rocket parts in the silo.
LuaLogisticNetworkLuaLogisticNetworkfalseThe logistic network this entity is a part of, or nil if this entity is not a part of any logistic network.
LuaLogisticCellunknownfalseThe logistic cell this entity is a part of. Will be nil if this entity is not a part of any logistic cell.
ItemWithQualityCountsunknownfalseItems this ghost will request when revived or items this item request proxy is requesting.
Array<BlueprintInsertPlan>Array<BlueprintInsertPlan>falseThe insert plan for this ghost or item request proxy.
Array<BlueprintInsertPlan>Array<BlueprintInsertPlan>falseThe removal plan for this item request proxy.
LuaPlayerunknowntrueThe player connected to this character, if any.
doubledoublefalseThe damage dealt by this turret, artillery turret, or artillery wagon.
uint32uint32falseThe number of units killed by this turret, artillery turret, or artillery wagon.
booleanbooleanfalseWhether this turret shoots at targets that are not on its priority list.
LuaPlayerPlayerIdentificationtrueThe last player that changed any setting on this entity. This includes building the entity, changing its color, or configuring its circuit network. nil if the last user is not part of the save anymore.
doubledoubletrueThe buffer size for the electric energy source. nil if the entity doesn't have an electric energy source.
Write access is limited to the ElectricEnergyInterface type.
doubleunknowntrueThe electric drain for the electric energy source. nil if the entity doesn't have an electric energy source.
Dict<string, double>unknowntrueThe table of emissions of this energy source in pollution/Joule, indexed by pollutant type. nil if the entity doesn't have an electric energy source. Multiplying values in the returned table by energy consumption in Watt gives pollution/second.
uint64unknowntrueA unique number identifying this entity for the lifetime of the save. These are allocated sequentially, and not re-used (until overflow).
Only entities inheriting from EntityWithOwnerPrototype, as well as ItemRequestProxyPrototype and EntityGhostPrototype are assigned a unit number. Returns nil otherwise.
uint64unknowntrueThe unit_number of the entity contained in this ghost. It is the same as the unit number of the EntityWithOwnerPrototype that was destroyed to create this ghost. If it was created by other means, or if the inner entity does not support unit numbers, this property is nil.
doubledoubletrueThe mining progress for this mining drill. Is a number in range [0, mining_target.prototype.mineable_properties.mining_time]. nil if this isn't a mining drill.
doubledoubletrueThe bonus mining progress for this mining drill. Read yields a number in range [0, mining_target.prototype.mineable_properties.mining_time]. nil if this isn't a mining drill.
BoundingBoxunknownfalseArea in which this mining drill looks for resources to mine.
doubledoublefalseThe power production specific to the ElectricEnergyInterface entity type.
doubledoublefalseThe power usage specific to the ElectricEnergyInterface entity type.
BoundingBoxunknownfalseLuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation.
BoundingBoxunknowntrueThe secondary bounding box of this entity or nil if it doesn't have one. This only exists for curved rails, and is automatically determined by the game.
BoundingBoxunknownfalseLuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation.
BoundingBoxunknowntrueThe secondary selection box of this entity or nil if it doesn't have one. This only exists for curved rails, and is automatically determined by the game.
LuaEntityunknowntrueThe mining target, if any.
uint32unknownfalseThe number of filter slots this inserter, loader, mining drill, asteroid collector or logistic storage container has. 0 if not one of those entities.
LuaEntityunknowntrueThe container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type, if any.
LuaEquipmentGridunknowntrueThis entity's equipment grid, if any.
uint8uint8trueThe graphics variation for this entity. nil if this entity doesn't use graphics variations.
uint8uint8falseIndex of the tree color.
uint8unknownfalseMaximum index of the tree colors.
uint8uint8falseIndex of the tree stage.
uint8unknownfalseMaximum index of the tree stages.
uint8uint8falseIndex of the tree gray stage
uint8unknownfalseMaximum index of the tree gray stages.
LuaBurnerunknowntrueThe burner energy source for this entity, if any.
LuaEntityLuaEntitytrueThe shooting target for this turret, if any. Can't be set to nil via script.
LuaEntityunknowntrueThe target entity for this item-request-proxy, if any.
Array<LuaEntity>unknowntrueThe sticker entities attached to this entity, if any.
LuaEntityunknownfalseThe entity this sticker is sticked to.
{ friction_modifier: double, speed_max: double, speed_modifier: double }unknowntrueThe vehicle modifiers applied to this entity through the attached stickers.
ProgrammableSpeakerParametersProgrammableSpeakerParametersfalseProgrammableSpeakerAlertParametersProgrammableSpeakerAlertParametersfalseLuaFlowStatisticsunknownfalseThe electric network statistics for this electric pole.
uint32unknownfalseReturns the current target pickup count of the inserter.
This considers the circuit network, manual override and the inserter stack size limit based on technology.
uint32uint32falseSets the stack size limit on this inserter.
Set to 0 to reset.
uint32uint32falseThe number of products this machine finished crafting in its lifetime.
doubleunknownfalsedoubleunknownfalsedoubleunknownfalseArray<LuaEntity>unknownfalseThe units associated with this spawner entity.
booleanbooleanfalseThe state of this power switch.
stringstringfalseThe description on this combinator.
ModuleEffectsunknowntrueThe effects being applied to this entity, if any. For beacons, this is the effect the beacon is broadcasting.
uint32unknowntrueNumber of beacons affecting this effect receiver. Can only be used when the entity has an effect receiver (AssemblingMachine, Furnace, Lab, MiningDrills)
Array<InfinityInventoryFilter>Array<InfinityInventoryFilter>falseThe filters for this infinity container.
booleanbooleanfalseWhether items not included in this infinity container filters should be removed from the container.
uint32uint32falseThe player index associated with this character corpse.
The index is not guaranteed to be valid so it should always be checked first if a player with that index actually exists.
uint32uint32falseThe tick this character corpse died at.
LocalisedStringLocalisedStringfalseThe reason this character corpse character died. "" if there is no reason.
LuaPlayerPlayerIdentificationtrueThe player this character is associated with, if any. Set to nil to clear.
The player will be automatically disassociated when a controller is set on the character. Also, all characters associated to a player will be logged off when the player logs off in multiplayer.
A character associated with a player is not directly controlled by any player.
uint32uint32falseThe last tick this character entity was attacked.
uint32uint32falseThe last tick this character entity was damaged.
ItemFilterItemFiltertrueThe filter for this splitter, if any is set.
"whitelist" | "blacklist""whitelist" | "blacklist"trueThe filter mode for this filter inserter. nil if this inserter doesn't use filters.
PrototypeFilterModePrototypeFilterModetrueThe filter mode for this loader. nil if this loader does not support filters.
uint8uint8falseThe belt stack size override for this loader. Set to 0 to disable. Writing this value requires LoaderPrototype::adjustable_belt_stack_size to be true.
"whitelist" | "blacklist""whitelist" | "blacklist"trueThe filter mode for this mining drill. nil if this mining drill doesn't have filters.
"left" | "none" | "right""left" | "none" | "right"falseThe input priority for this splitter.
"left" | "none" | "right""left" | "none" | "right"falseThe output priority for this splitter.
SpoilPrioritySpoilPriorityfalseThe spoil priority for this inserter.
booleanunknownfalseWhether this land mine is armed.
booleanbooleanfalseWhen locked; the recipe in this assembling machine can't be changed by the player.
LuaEntityunknowntrueThe rail entity this train stop is connected to, if any.
defines.rail_directionunknownfalseRail direction to which this train stop is binding. This returns a value even when no rails are present.
uint32unknownfalseThe number of trains in this rail block for this rail entity.
uint32uint32falseThe timeout that's left on this landmine in ticks. It describes the time between the landmine being placed and it being armed.
doubleunknownfalseThe current total neighbour bonus of this reactor.
LuaAISettingsunknownfalseThe ai settings of this unit.
CursorBoxRenderTypeCursorBoxRenderTypefalseThe highlight box type of this highlight box entity.
uint32uint32falseThe blink interval of this highlight box entity. 0 indicates no blink.
defines.entity_statusunknowntrueThe status of this entity, if any.
This is always the actual status of the entity, even if LuaEntity::custom_status is set.
CustomEntityStatusCustomEntityStatustrueA custom status for this entity that will be displayed in the GUI.
booleanbooleanfalseWhether equipment grid logistics are enabled while this vehicle is moving.
LuaPlayerPlayerIdentificationtrueThe player that this simple-entity-with-owner, simple-entity-with-force, or highlight-box is visible to. nil when this entity is rendered for all players.
ForceSetForceSettrueThe forces that this simple-entity-with-owner or simple-entity-with-force is visible to. nil or an empty array when this entity is rendered for all forces.
Reading will always give an array of LuaForce
LuaEntityunknowntrueThe rail target of this pump, if any.
floatfloattrueThe threshold override of this valve, or nil if an override is not defined.
If no override is defined, the threshold is taken from LuaEntityPrototype::valve_threshold.
uint32unknowntrueReturns the id of the electric network that this entity is connected to, if any.
booleanbooleanfalseWhether this character's personal roboports are allowed to dispatch robots.
doubleunknownfalseHow much energy this generator generated in the last tick.
ItemIDAndQualityIDPairItemWithQualityIDtrueThe storage filter for this logistic storage container.
Useable only on logistic containers with the "storage" logistic_mode.
booleanbooleanfalseWhether this requester chest is set to also request from buffer chests.
Useable only on entities that have requester slots.
booleanbooleanfalseWhether this corpse will ever fade away.
booleanbooleanfalseIf 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.
TagsTagstrueThe tags associated with this entity ghost. nil if this is not an entity ghost or when the ghost has no tags.
uint32uint32falseThe ticks until the next trigger effect of this smoke-with-trigger.
MapPositionMapPositiontrueDestination of this spidertron's autopilot, if any. Writing nil clears all destinations.
Array<MapPosition>unknownfalseThe queued destination positions of spidertron's autopilot.
uint32unknownfalseAmount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint.
Train may be included multiple times when braking distance covers this train stop multiple times.
Value may be read even when train stop has no control behavior.
uint32uint32falseAmount of trains above which no new trains will be sent to this train stop. Writing nil will disable the limit (will set a maximum possible value).
When a train stop has a control behavior with wire connected and set_trains_limit enabled, this value will be overwritten by it.
booleanbooleanfalseWhether this entity is a MilitaryTarget. Can be written to if LuaEntityPrototype::allow_run_time_change_of_is_military_target returns true.
booleanunknownfalseIf this entity is EntityWithOwner
booleanunknownfalseIf this entity is EntityWithHealth
LuaEntityLuaEntitytrueThe owner of this combat robot, if any.
uint32uint32falseThe link ID this linked container is using.
LuaEntityLuaEntitytrueThe follow target of this spidertron, if any.
VectorVectortrueThe follow offset of this spidertron, if any entity is being followed. This is randomized each time the follow entity is set.
BeltConnectionTypeBeltConnectionTypefalseType of linked belt. Changing type will also flip direction so the belt is out of the same side.
Can only be changed when linked belt is disconnected (has no neighbour set).
LuaEntityunknowntrueNeighbour to which this linked belt is connected to, if any.
May return entity ghost which contains linked belt to which connection is made.
LuaQualityPrototypeunknownfalseThe quality of this entity.
Not all entities support quality and will give the "normal" quality back if they don't.
defines.rail_layerunknownfalseGets rail layer of a given signal
floatunknownfalseThe current radar scan progress, as a number in range [0, 1].
stringstringfalseName tag of this entity. Returns nil if entity has no name tag. When name tag is already used by other entity, the name will be removed from the other entity. Entity name tags can also be set in the entity "extra settings" GUI in the map editor.
defines.rocket_silo_statusunknownfalseThe status of this rocket silo entity.
uint32unknownfalseSpecifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). Uses the current direction of the entity.
uint32unknownfalseSpecifies the tiling size of the entity, is used to decide, if the center should be in the center of the tile (odd tile size dimension) or on the tile border (even tile size dimension). Uses the current direction of the entity.
Vector3DunknownfalseReturns current position in 3D for the end of the crane of this entity.
MapPositionMapPositionfalseDestination of the crane of this entity. Throws when trying to set the destination out of range.
Vector3DVector3DfalseDestination of the crane of this entity in 3D. Throws when trying to set the destination out of range.
unknownMapPositionfalseWill set destination for the grappler of crane of this entity. The crane grappler will start moving to reach the destination, but the rest of the arm will remain stationary. Throws when trying to set the destination out of range.
unknownVector3DfalseWill set destination in 3D for the grappler of crane of this entity. The crane grappler will start moving to reach the destination, but the rest of the arm will remain stationary. Throws when trying to set the destination out of range.
Array<LuaEntity>unknownfalsePlants registered by this agricultural tower. One plant can be registered in multiple agricultural towers.
booleanbooleanfalseIf this rolling stock has 'copy color from train stop' enabled.
booleanunknownfalseIf the rolling stock is facing train's front.
RollingStockDrawDataunknownfalseGives a draw data of the given entity if it supports such data.
uint8uint8falsePriority of this train stop.
"straight" | "left" | "right"unknownfalseGives what is the current shape of a transport-belt.
stringunknownfalseReturns a rich text string containing this entity's position and surface name as a gps tag. Printing it will ping the location of the entity.
LuaCommandableunknowntrueReturns a LuaCommandable for this entity or nil if entity is not commandable. Units and SpiderUnits are commandable.
uint32unknownfalseReturns count of fluid storages. This includes fluid storages provided by fluidboxes but also covers other fluid storages like fluid turret's internal buffer and fluid wagon's fluid since they are not fluidbox and cannot be exposed through LuaFluidBox.
MapTickMapTickfalseThe tick when this plant is fully grown.
booleanbooleanfalseIf the lamp is always on when not driven by control behavior.
booleanbooleanfalseIf this artillery auto-targets enemies.
Array<WorkerRobotOrder>unknownfalseGet the current queue of robot orders.
MapTickMapTickfalsehow far into the current procession the cargo pod is.
booleanunknownfalseWhether the entity is updatable and considered an UpdatableEntity.
booleanbooleanfalseIf the updatable entity is disabled by script.
Note: Some entities (Corpse, FireFlame, Roboport, RollingStock, dying entities) need to remain active and will ignore writes.
If this entity is not considered updatable then this always returns false and writes will be ignored.
booleanunknownfalseIf the updatable entity is disabled by control behavior.
Always returns false if this entity is not considered updatable.
booleanunknownfalseIf the assembling machine is disabled by recipe, e.g. due to AssemblingMachinePrototype::disabled_when_recipe_not_researched.
Always returns false if this entity is not considered updatable.
booleanunknownfalseWhether the entity is freezable and considered a FreezableEntity.
booleanunknownfalseWhether the freezable entity is currently frozen.
Always returns false if this entity is not considered freezable.
Array<LuaCargoHatch>unknownfalseThe cargo hatches owned by this entity if any.
"awaiting_launch" | "ascending" | "surface_transition" | "descending" | "parking"unknownfalseThe state of this cargo pod entity.
CargoDestinationCargoDestinationfalseThe destination of this cargo pod entity.
Use force_finish_ascending if you want it to only descend from orbit.
LuaEntityLuaEntitytrueThe origin of this cargo pod entity. (Must be a silo, hub or pad)
LuaEntityunknowntrueThe cargo pod attached to this rocket silo rocket if any.
LuaEntityunknowntrueThe rocket silo rocket this cargo pod is attached to, or rocket silo rocket attached to this rocket silo - if any.
LuaEntityunknowntrueThe first found item request proxy targeting this entity.
TriggerModifierDataTriggerModifierDatafalseTriggerModifierDataTriggerModifierDatafalseLuaEntityunknowntrueThe space platform hub or cargo landing pad this cargo bay is connected to if any.
booleanbooleanfalseFor inserters taking items from transport belt connectables, this determines whether the inserter is allowed to take items from the left lane.
booleanbooleanfalseFor inserters taking items from transport belt connectables, this determines whether the inserter is allowed to take items from the right lane.
LuaSegmentedUnitunknowntrueThe segmented unit object that the segment entity is a part of.
doubleunknownfalseThe amount of fluid moved by this offshore pump or normal pump in the last tick.
LuaEntityunknowntrueThe corpse that caused this entity ghost to be created, if any.
Array<LuaEntityPrototype>unknownfalseThe priority targets for this turret (if any).
LuaEntityLuaEntitytrueEntity of which inventory is exposed by this ProxyContainer
defines.inventorydefines.inventoryfalseInventory index of the inventory that is exposed by this ProxyContainer
LocalisedStringLocalisedStringfalseText visible on the display panel. Can be written only when it is not set by control behavior.
SignalIDSignalIDtrueIcon visible on the display panel. Can be written only when it is not set by control behavior.
booleanbooleanfalsebooleanbooleanfalsebooleanunknownfalseIs this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.
stringunknownfalseThe class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.
LuaEntity.get_output_inventory() -> LuaInventory?
entity.get_output_inventory()
takes_table: falsetable_optional: falseGets the entity's output inventory if it has one.
LuaInventory? — A reference to the entity's output inventory.LuaEntity.get_module_inventory() -> LuaInventory?
entity.get_module_inventory()
takes_table: falsetable_optional: falseInventory for storing modules of this entity; nil if this entity has no module inventory.
LuaInventory?LuaEntity.get_fuel_inventory() -> LuaInventory?
entity.get_fuel_inventory()
takes_table: falsetable_optional: falseThe fuel inventory for this entity or nil if this entity doesn't have a fuel inventory.
LuaInventory?LuaEntity.get_burnt_result_inventory() -> LuaInventory?
entity.get_burnt_result_inventory()
takes_table: falsetable_optional: falseThe burnt result inventory for this entity or nil if this entity doesn't have a burnt result inventory.
LuaInventory?LuaEntity.damage(damage: float, force: ForceID, type?: DamageTypeID, source?: LuaEntity, cause?: LuaEntity) -> float
entity.damage(damage, force, type)
takes_table: falsetable_optional: falseDamages the entity.
damage: float — The amount of damage to be done.force: ForceID — The force that will be doing the damage.type?: DamageTypeID — The type of damage to be done, defaults to "impact".source?: LuaEntity — The entity that is directly dealing the damage (e.g. the projectile, flame, sticker, grenade, laser beam, etc.). Needs to be on the same surface as the entity being damaged.cause?: LuaEntity — The entity that originally triggered the events that led to this damage being dealt (e.g. the character, turret, enemy, etc. that pulled the trigger). Does not need to be on the same surface as the entity being damaged.float — the total damage actually applied after resistances.LuaEntity.can_be_destroyed() -> boolean
entity.can_be_destroyed()
takes_table: falsetable_optional: falseWhether the entity can be destroyed
booleanLuaEntity.destroy{ do_cliff_correction?: boolean, raise_destroy?: boolean, player?: PlayerIdentification, undo_index?: uint32 } -> boolean
entity.destroy{ raise_destroy=true }
takes_table: truetable_optional: trueDestroys the entity.
Not all entities can be destroyed - things such as rails under trains cannot be destroyed until the train is moved or destroyed.
do_cliff_correction?: boolean — Whether neighbouring cliffs should be corrected. Defaults to false.raise_destroy?: boolean — If true, script_raised_destroy will be called. Defaults to false.player?: PlayerIdentification — The player whose undo queue this action should be added to.undo_index?: uint32 — The index of the undo item to add this action to. An index of 0 creates a new undo item for it. Defaults to putting it into the appropriate undo item automatically if not specified.boolean — Returns false if the entity was valid and destruction failed, true in all other cases.LuaEntity.die(force?: ForceID, cause?: LuaEntity) -> boolean
entity.die()
takes_table: falsetable_optional: falseImmediately 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?: ForceID — The force to attribute the kill to.cause?: LuaEntity — The cause to attribute the kill to.boolean — Whether the entity was successfully killed.LuaEntity.has_flag(flag: EntityPrototypeFlag) -> boolean
entity.has_flag(flag)
takes_table: falsetable_optional: falseTest whether this entity's prototype has a certain flag set.
entity.has_flag(f) is a shortcut for entity.prototype.has_flag(f).
flag: EntityPrototypeFlag — The flag to test.boolean — true if this entity has the given flag set.LuaEntity.ghost_has_flag(flag: EntityPrototypeFlag) -> boolean
entity.ghost_has_flag(flag)
takes_table: falsetable_optional: falseSame as LuaEntity::has_flag, but targets the inner entity on a entity ghost.
flag: EntityPrototypeFlag — The flag to test.boolean — true if the entity has the given flag set.LuaEntity.add_market_item(offer: Offer)
entity.add_market_item(offer)
takes_table: falsetable_optional: falseOffer a thing on the market.
offer: OfferLuaEntity.remove_market_item(offer: uint32) -> boolean
entity.remove_market_item(offer)
takes_table: falsetable_optional: falseRemove an offer from a market.
The other offers are moved down to fill the gap created by removing the offer, which decrements the overall size of the offer array.
offer: uint32 — Index of offer to remove.boolean — true if the offer was successfully removed; false when the given index was not valid.LuaEntity.get_market_items() -> Array<Offer>
entity.get_market_items()
takes_table: falsetable_optional: falseGet all offers in a market as an array.
Array<Offer>LuaEntity.clear_market_items()
entity.clear_market_items()
takes_table: falsetable_optional: falseRemoves all offers from a market.
LuaEntity.order_deconstruction(force: ForceID, player?: PlayerIdentification, undo_index?: uint32) -> boolean
entity.order_deconstruction(force, player)
takes_table: falsetable_optional: falseSets the entity to be deconstructed by construction robots.
force: ForceID — The force whose robots are supposed to do the deconstruction.player?: PlayerIdentification — The player to set the last_user to, if any. Also the player whose undo queue this action should be added to.undo_index?: uint32 — The index of the undo item to add this action to. An index of 0 creates a new undo item for it. An index of 1 adds the action to the latest undo action on the stack. Defaults to putting it into the appropriate undo item automatically if one is not specified.boolean — if the entity was marked for deconstruction.LuaEntity.cancel_deconstruction(force: ForceID, player?: PlayerIdentification)
entity.cancel_deconstruction(force, player)
takes_table: falsetable_optional: falseCancels deconstruction if it is scheduled, does nothing otherwise.
force: ForceID — The force who did the deconstruction order.player?: PlayerIdentification — The player to set the last_user to if any.LuaEntity.to_be_deconstructed() -> boolean
entity.to_be_deconstructed()
takes_table: falsetable_optional: falseIs this entity marked for deconstruction?
booleanLuaEntity.order_upgrade{ target: EntityWithQualityID, force: ForceID, player?: PlayerIdentification, undo_index?: uint32 } -> boolean
entity.order_upgrade{ target=target, force=force }
takes_table: truetable_optional: falseSets the entity to be upgraded by construction robots.
target: EntityWithQualityID — The prototype of the entity to upgrade to.force: ForceID — The force whose robots are supposed to do the upgrade.player?: PlayerIdentification — The player whose undo queue this action should be added to.undo_index?: uint32 — The index of the undo item to add this action to. An index of 0 creates a new undo item for it. Defaults to putting it into the appropriate undo item automatically if not specified.boolean — Whether the entity was marked for upgrade.LuaEntity.cancel_upgrade(force: ForceID, player?: PlayerIdentification) -> boolean
entity.cancel_upgrade(force, player)
takes_table: falsetable_optional: falseCancels upgrade if it is scheduled, does nothing otherwise.
force: ForceID — The force who did the upgrade order.player?: PlayerIdentification — The player to set the last_user to if any.boolean — Whether the cancel was successful.LuaEntity.to_be_upgraded() -> boolean
entity.to_be_upgraded()
takes_table: falsetable_optional: falseIs this entity marked for upgrade?
booleanLuaEntity.apply_upgrade() -> LuaEntity?, LuaEntity?
entity.apply_upgrade()
takes_table: falsetable_optional: falseUpgrades this entity in place if it's marked to be upgraded.
LuaEntity? — The first upgraded entity - nil if this entity is not marked for upgrade.LuaEntity? — The second upgraded entity - nil if this entity is not marked for upgrade.LuaEntity.is_crafting() -> boolean
entity.is_crafting()
takes_table: falsetable_optional: falseReturns whether a craft is currently in process. It does not indicate whether progress is currently being made, but whether a crafting process has been started in this machine.
booleanLuaEntity.is_opened() -> boolean
entity.is_opened()
takes_table: falsetable_optional: falseboolean — true if this gate is currently opened.LuaEntity.is_opening() -> boolean
entity.is_opening()
takes_table: falsetable_optional: falseboolean — true if this gate is currently opening.LuaEntity.is_closed() -> boolean
entity.is_closed()
takes_table: falsetable_optional: falseboolean — true if this gate is currently closed.LuaEntity.is_closing() -> boolean
entity.is_closing()
takes_table: falsetable_optional: falseboolean — true if this gate is currently closingLuaEntity.request_to_open(force: ForceID, extra_time?: uint32)
entity.request_to_open(force, extra_time)
takes_table: falsetable_optional: falseforce: ForceID — The force that requests the gate to be open.extra_time?: uint32 — Extra ticks to stay open.LuaEntity.request_to_close(force: ForceID)
entity.request_to_close(force)
takes_table: falsetable_optional: falseforce: ForceID — The force that requests the gate to be closed.LuaEntity.get_transport_line(index: uint32) -> LuaTransportLine
entity.get_transport_line(index)
takes_table: falsetable_optional: falseGet a transport line of a belt or belt connectable entity.
index: uint32 — Index of the requested transport line. Transport lines are 1-indexed.LuaTransportLineLuaEntity.get_item_insert_specification(position: MapPosition) -> uint32, float
entity.get_item_insert_specification(position)
takes_table: falsetable_optional: falseGet an item insert specification onto a belt connectable: for a given map position provides into which line at what position item should be inserted to be closest to the provided position.
position: MapPosition — Position where the item is to be inserted.uint32 — Index of the transport line that is closest to the provided map position.float — Position along the transport line where item should be dropped.LuaEntity.get_line_item_position(index: uint32, position: float) -> MapPosition
entity.get_line_item_position(index, position)
takes_table: falsetable_optional: falseGet a map position related to a position on a transport line.
index: uint32 — Index of the transport line. Transport lines are 1-indexed.position: float — Linear position along the transport line. Clamped to the transport line range.MapPositionLuaEntity.get_max_transport_line_index() -> uint32
entity.get_max_transport_line_index()
takes_table: falsetable_optional: falseGet the maximum transport line index of a belt or belt connectable entity.
uint32LuaEntity.launch_rocket(destination?: CargoDestination, character?: LuaEntity) -> boolean
entity.launch_rocket()
takes_table: falsetable_optional: falsedestination?: CargoDestinationcharacter?: LuaEntity — If provided, must be of character type.boolean — true if the rocket was successfully launched. Return value of false means the silo is not ready for launch.LuaEntity.revive{ raise_revive?: boolean, overflow?: LuaInventory } -> Dict<string, uint32>?, LuaEntity?, LuaEntity?
entity.revive{ raise_revive=true }
takes_table: truetable_optional: trueRevive a ghost, which turns it from a ghost into a real entity or tile.
raise_revive?: boolean — If true, and an entity ghost; script_raised_revive will be called. Else if true, and a tile ghost; script_raised_set_tiles will be called.overflow?: LuaInventory — Items that would be deleted will be transferred to this inventory. Must be a script inventory or inventory of other entity. Inventory references obtained from proxy container are not allowed.Dict<string, uint32>? — Any items the new real entity collided with or nil if the ghost could not be revived.LuaEntity? — The revived entity if an entity ghost was successfully revived.LuaEntity? — The item request proxy if one was created.LuaEntity.silent_revive{ raise_revive?: boolean, overflow?: LuaInventory } -> ItemWithQualityCounts, LuaEntity?, LuaEntity?
entity.silent_revive{ raise_revive=true }
takes_table: truetable_optional: trueRevives a ghost silently, so the revival makes no sound and no smoke is created.
raise_revive?: boolean — If true, and an entity ghost; script_raised_revive will be called. Else if true, and a tile ghost; script_raised_set_tiles will be called.overflow?: LuaInventory — Items that would be deleted will be transferred to this inventory. Must be a script inventory or inventory of other entity. Inventory references obtained from proxy container are not allowed.ItemWithQualityCounts — Any items the new real entity collided with or nil if the ghost could not be revived.LuaEntity? — The revived entity if an entity ghost was successfully revived.LuaEntity? — The item request proxy if one was created.LuaEntity.get_connected_rail{ rail_direction: defines.rail_direction, rail_connection_direction: defines.rail_connection_direction } -> LuaEntity?, defines.rail_direction?, defines.rail_connection_direction?
entity.get_connected_rail{ rail_direction=rail_direction, rail_connection_direction=rail_connection_direction }
takes_table: truetable_optional: falserail_direction: defines.rail_directionrail_connection_direction: defines.rail_connection_directionLuaEntity? — Rail connected in the specified manner to this one, nil if unsuccessful.defines.rail_direction? — Rail direction of the returned rail which points to origin raildefines.rail_connection_direction? — Turn to be taken when going back from returned rail to origin railLuaEntity.get_connected_rails() -> Array<LuaEntity>
entity.get_connected_rails()
takes_table: falsetable_optional: falseGet the rails that this signal is connected to.
Array<LuaEntity>LuaEntity.get_rail_segment_signal(direction: defines.rail_direction, in_else_out: boolean) -> LuaEntity?
entity.get_rail_segment_signal(direction, true)
takes_table: falsetable_optional: falseGet the rail signal at the start/end of the rail segment this rail is in.
A rail segment is a continuous section of rail with no branches, signals, nor train stops.
direction: defines.rail_direction — The direction of travel relative to this rail.in_else_out: boolean — If true, gets the signal at the entrance of the rail segment, otherwise gets the signal at the exit of the rail segment.LuaEntity? — nil if the rail segment doesn't start/end with a signal.LuaEntity.get_rail_segment_stop(direction: defines.rail_direction) -> LuaEntity?
entity.get_rail_segment_stop(direction)
takes_table: falsetable_optional: falseGet train stop at the start/end of the rail segment this rail is in.
A rail segment is a continuous section of rail with no branches, signals, nor train stops.
direction: defines.rail_direction — The direction of travel relative to this rail.LuaEntity? — nil if the rail segment doesn't start/end with a train stop.LuaEntity.get_rail_segment_end(direction: defines.rail_direction) -> LuaEntity, defines.rail_direction
entity.get_rail_segment_end(direction)
takes_table: falsetable_optional: falseGet the rail at the end of the rail segment this rail is in.
A rail segment is a continuous section of rail with no branches, signals, nor train stops.
direction: defines.rail_directionLuaEntity — The rail entity.defines.rail_direction — A rail direction pointing out of the rail segment from the end rail.LuaEntity.get_rail_segment_rails(direction: defines.rail_direction) -> Array<LuaEntity>
entity.get_rail_segment_rails(direction)
takes_table: falsetable_optional: falseGet all rails of a rail segment this rail is in
A rail segment is a continuous section of rail with no branches, signals, nor train stops.
direction: defines.rail_direction — Selects end of this rail that points to a rail segment end from which to start returning railsArray<LuaEntity> — Rails of this rail segmentLuaEntity.get_rail_segment_length() -> double
entity.get_rail_segment_length()
takes_table: falsetable_optional: falseGet the length of the rail segment this rail is in.
A rail segment is a continuous section of rail with no branches, signals, nor train stops.
doubleLuaEntity.get_rail_segment_overlaps() -> Array<LuaEntity>
entity.get_rail_segment_overlaps()
takes_table: falsetable_optional: falseGet a rail from each rail segment that overlaps with this rail's rail segment.
A rail segment is a continuous section of rail with no branches, signals, nor train stops.
Array<LuaEntity>LuaEntity.is_rail_in_same_rail_segment_as(other_rail: LuaEntity) -> boolean
entity.is_rail_in_same_rail_segment_as(other_rail)
takes_table: falsetable_optional: falseChecks if this rail and other rail both belong to the same rail segment.
other_rail: LuaEntitybooleanLuaEntity.is_rail_in_same_rail_block_as(other_rail: LuaEntity) -> boolean
entity.is_rail_in_same_rail_block_as(other_rail)
takes_table: falsetable_optional: falseChecks if this rail and other rail both belong to the same rail block.
other_rail: LuaEntitybooleanLuaEntity.get_parent_signals() -> Array<LuaEntity>
entity.get_parent_signals()
takes_table: falsetable_optional: falseReturns all parent signals. Parent signals are always RailChainSignal. Parent signals are those signals that are checking state of this signal to determine their own chain state.
Array<LuaEntity>LuaEntity.get_child_signals() -> Array<LuaEntity>
entity.get_child_signals()
takes_table: falsetable_optional: falseReturns all child signals. Child signals can be either RailSignal or RailChainSignal. Child signals are signals which are checked by this signal to determine a chain state.
Array<LuaEntity>LuaEntity.get_inbound_signals() -> Array<LuaEntity>
entity.get_inbound_signals()
takes_table: falsetable_optional: falseReturns all signals guarding entrance to a rail block this rail belongs to.
Array<LuaEntity>LuaEntity.get_outbound_signals() -> Array<LuaEntity>
entity.get_outbound_signals()
takes_table: falsetable_optional: falseReturns all signals guarding exit from a rail block this rail belongs to.
Array<LuaEntity>LuaEntity.get_filter(slot_index: uint32) -> ItemFilter | EntityID | AsteroidChunkID?
entity.get_filter(slot_index)
takes_table: falsetable_optional: falseGet the filter for a slot in an inserter, loader, mining drill, asteroid collector, or logistic storage container. The entity must allow filters.
slot_index: uint32 — Index of the slot to get the filter for.ItemFilter | EntityID | AsteroidChunkID? — The filter, or nil if the given slot has no filter.LuaEntity.set_filter(index: uint32, filter?: ItemFilter | ItemWithQualityID | EntityID | AsteroidChunkID)
entity.set_filter(index, filter)
takes_table: falsetable_optional: falseSet the filter for a slot in an inserter (ItemFilter), loader (ItemFilter), mining drill (EntityID), asteroid collector (AsteroidChunkID) or logistic storage container (ItemWithQualityID). The entity must allow filters.
index: uint32 — Index of the slot to set the filter for.filter?: ItemFilter | ItemWithQualityID | EntityID | AsteroidChunkID — The item or entity to filter, or nil to clear the filter.LuaEntity.get_infinity_container_filter(index: uint32) -> InfinityInventoryFilter?
entity.get_infinity_container_filter(index)
takes_table: falsetable_optional: falseGets the filter for this infinity container at the given index, or nil if the filter index doesn't exist or is empty.
index: uint32 — The index to get.InfinityInventoryFilter?LuaEntity.set_infinity_container_filter(index: uint32, filter: InfinityInventoryFilter | nil)
entity.set_infinity_container_filter(index, filter)
takes_table: falsetable_optional: falseSets the filter for this infinity container at the given index.
index: uint32 — The index to set.filter: InfinityInventoryFilter | nil — The new filter, or nil to clear the filter.LuaEntity.get_infinity_pipe_filter() -> InfinityPipeFilter?
entity.get_infinity_pipe_filter()
takes_table: falsetable_optional: falseGets the filter for this infinity pipe, or nil if the filter is empty.
InfinityPipeFilter?LuaEntity.set_infinity_pipe_filter(filter: InfinityPipeFilter | nil)
entity.set_infinity_pipe_filter(filter)
takes_table: falsetable_optional: falseSets the filter for this infinity pipe.
filter: InfinityPipeFilter | nil — The new filter, or nil to clear the filter.LuaEntity.get_heat_setting() -> HeatSetting
entity.get_heat_setting()
takes_table: falsetable_optional: falseGets the heat setting for this heat interface.
HeatSettingLuaEntity.set_heat_setting(filter: HeatSetting)
entity.set_heat_setting(filter)
takes_table: falsetable_optional: falseSets the heat setting for this heat interface.
filter: HeatSetting — The new setting.LuaEntity.get_control_behavior() -> LuaControlBehavior?
entity.get_control_behavior()
takes_table: falsetable_optional: falseGets the control behavior of the entity (if any).
LuaControlBehavior? — The control behavior or nil.LuaEntity.get_or_create_control_behavior() -> LuaControlBehavior?
entity.get_or_create_control_behavior()
takes_table: falsetable_optional: falseGets (and or creates if needed) the control behavior of the entity.
LuaControlBehavior? — The control behavior or nil.LuaEntity.get_circuit_network(wire_connector_id: defines.wire_connector_id) -> LuaCircuitNetwork?
entity.get_circuit_network(wire_connector_id)
takes_table: falsetable_optional: falsewire_connector_id: defines.wire_connector_id — Wire connector to get circuit network for.LuaCircuitNetwork? — The circuit network or nil.LuaEntity.get_signal(signal: SignalID, wire_connector_id: defines.wire_connector_id, extra_wire_connector_id?: defines.wire_connector_id) -> int32
entity.get_signal(signal, wire_connector_id, extra_wire_connector_id)
takes_table: falsetable_optional: falseRead a single signal from the selected wire connector
signal: SignalID — The signal to read.wire_connector_id: defines.wire_connector_id — Wire connector ID from which to get the signalextra_wire_connector_id?: defines.wire_connector_id — Additional wire connector ID. If specified, signal will be added to the resultint32 — The current value of the signal.LuaEntity.get_signals(wire_connector_id: defines.wire_connector_id, extra_wire_connector_id?: defines.wire_connector_id) -> Array<Signal>?
entity.get_signals(wire_connector_id, extra_wire_connector_id)
takes_table: falsetable_optional: falseRead all signals from the selected wire connector.
wire_connector_id: defines.wire_connector_id — Wire connector ID from which to get the signalextra_wire_connector_id?: defines.wire_connector_id — Additional wire connector ID. If specified, signals will be added to the resultArray<Signal>? — Current values of all signals.LuaEntity.supports_backer_name() -> boolean
entity.supports_backer_name()
takes_table: falsetable_optional: falseWhether this entity supports a backer name.
booleanLuaEntity.copy_settings(entity: LuaEntity, by_player?: PlayerIdentification) -> ItemWithQualityCounts
entity.copy_settings(entity, by_player)
takes_table: falsetable_optional: falseCopies settings from the given entity onto this entity.
entity: LuaEntityby_player?: PlayerIdentification — If provided, the copying is done 'as' this player and on_entity_settings_pasted is triggered.ItemWithQualityCounts — Any items removed from this entity as a result of copying the settings.LuaEntity.get_logistic_point(index?: defines.logistic_member_index) -> LuaLogisticPoint | Array<LuaLogisticPoint>?
entity.get_logistic_point()
takes_table: falsetable_optional: falseGets all the LuaLogisticPoints that this entity owns. Optionally returns only the point specified by the index parameter.
index?: defines.logistic_member_index — If provided, this method only returns the LuaLogisticPoint specified by this index, or nil if it doesn't exist.LuaLogisticPoint | Array<LuaLogisticPoint>?LuaEntity.play_note(instrument: uint32, note: uint32, stop_playing_sounds?: boolean) -> boolean
entity.play_note(instrument, note, true)
takes_table: falsetable_optional: falsePlays a note with the given instrument and note.
instrument: uint32note: uint32stop_playing_sounds?: booleanboolean — Whether the request is valid. The sound may or may not be played depending on polyphony settings.LuaEntity.connect_rolling_stock(direction: defines.rail_direction) -> boolean
entity.connect_rolling_stock(direction)
takes_table: falsetable_optional: falseConnects the rolling stock in the given direction.
direction: defines.rail_directionboolean — Whether any connection was madeLuaEntity.disconnect_rolling_stock(direction: defines.rail_direction) -> boolean
entity.disconnect_rolling_stock(direction)
takes_table: falsetable_optional: falseTries to disconnect this rolling stock in the given direction.
direction: defines.rail_directionboolean — If anything was disconnectedLuaEntity.update_connections()
entity.update_connections()
takes_table: falsetable_optional: falseReconnect loader, beacon, cliff and mining drill connections to entities that might have been teleported out or in by the script. The game doesn't do this automatically as we don't want to lose performance by checking this in normal games.
LuaEntity.get_recipe() -> LuaRecipe?, LuaQualityPrototype?
entity.get_recipe()
takes_table: falsetable_optional: falseCurrent recipe being assembled by this machine, if any.
LuaRecipe?LuaQualityPrototype?LuaEntity.set_recipe(recipe?: RecipeID, quality?: QualityID) -> ItemWithQualityCounts
entity.set_recipe()
takes_table: falsetable_optional: falseSets the given recipe in this assembly machine.
recipe?: RecipeID — The new recipe. Writing nil clears the recipe, if any.quality?: QualityID — The quality. If not provided normal is used.ItemWithQualityCounts — Any items removed from this entity as a result of setting the recipe.LuaEntity.rotate{ reverse?: boolean, by_player?: PlayerIdentification } -> boolean
entity.rotate{ reverse=true }
takes_table: truetable_optional: trueRotates this entity as if the player rotated it.
reverse?: boolean — If true, rotate the entity in the counter-clockwise direction.by_player?: PlayerIdentificationboolean — Whether the rotation was successful.LuaEntity.get_driver() -> LuaEntity | LuaPlayer?
entity.get_driver()
takes_table: falsetable_optional: falseGets the driver of this vehicle if any.
LuaEntity | LuaPlayer? — nil if the vehicle contains no driver. To check if there's a passenger see LuaEntity::get_passenger.LuaEntity.set_driver(driver: LuaEntity | PlayerIdentification | nil)
entity.set_driver(driver)
takes_table: falsetable_optional: falseSets the driver of this vehicle.
This differs from LuaEntity::set_passenger in that the passenger can't drive the vehicle.
driver: LuaEntity | PlayerIdentification | nil — The new driver. Writing nil ejects the current driver, if any.LuaEntity.get_passenger() -> LuaEntity | LuaPlayer?
entity.get_passenger()
takes_table: falsetable_optional: falseGets the passenger of this car, spidertron, or cargo pod if any.
This differs over LuaEntity::get_driver in that for cars, the passenger can't drive the car.
LuaEntity | LuaPlayer? — nil if the vehicle contains no passenger. To check if there's a driver see LuaEntity::get_driver.LuaEntity.set_passenger(passenger: LuaEntity | PlayerIdentification | nil)
entity.set_passenger(passenger)
takes_table: falsetable_optional: falseSets the passenger of this car, spidertron, or cargo pod.
This differs from LuaEntity::get_driver in that the passenger can't drive the car.
passenger: LuaEntity | PlayerIdentification | nil — The new passenger. Writing nil ejects the current passenger, if any.LuaEntity.is_connected_to_electric_network() -> boolean
entity.is_connected_to_electric_network()
takes_table: falsetable_optional: falseReturns true if this entity produces or consumes electricity and is connected to an electric network that has at least one entity that can produce power.
booleanLuaEntity.get_train_stop_trains() -> Array<LuaTrain>
entity.get_train_stop_trains()
takes_table: falsetable_optional: falseThe trains scheduled to stop at this train stop.
Array<LuaTrain>LuaEntity.get_stopped_train() -> LuaTrain?
entity.get_stopped_train()
takes_table: falsetable_optional: falseThe train currently stopped at this train stop, if any.
LuaTrain?LuaEntity.clone{ position: MapPosition, surface?: LuaSurface, force?: ForceID, create_build_effect_smoke?: boolean } -> LuaEntity?
entity.clone{ position=position }
takes_table: truetable_optional: falseClones this entity.
position: MapPosition — The destination positionsurface?: LuaSurface — The destination surfaceforce?: ForceIDcreate_build_effect_smoke?: boolean — If false, the building effect smoke will not be shown around the new entity.LuaEntity? — The cloned entity or nil if this entity can't be cloned/can't be cloned to the given location.LuaEntity.get_fluid_count(fluid?: string) -> double
entity.get_fluid_count()
takes_table: falsetable_optional: falseGet the amount of all or some fluid in this entity.
If information about fluid temperatures is required, LuaEntity::fluidbox should be used instead.
fluid?: string — Prototype name of the fluid to count. If not specified, count all fluids.doubleLuaEntity.get_fluid_contents() -> Dict<string, FluidAmount>
entity.get_fluid_contents()
takes_table: falsetable_optional: falseGet amounts of all fluids in this entity.
If information about fluid temperatures is required, LuaEntity::get_fluid or LuaEntity::fluidbox should be used instead.
Dict<string, FluidAmount> — The amounts, indexed by fluid names.LuaEntity.remove_fluid{ name: string, amount: double, minimum_temperature?: double, maximum_temperature?: double, temperature?: double } -> double
entity.remove_fluid{ name=name, amount=amount }
takes_table: truetable_optional: falseRemove fluid from this entity.
If temperature is given only fluid matching that exact temperature is removed. If minimum and maximum is given fluid within that range is removed.
name: string — Fluid prototype name.amount: double — Amount to removeminimum_temperature?: doublemaximum_temperature?: doubletemperature?: doubledouble — Amount of fluid actually removed.LuaEntity.insert_fluid(fluid: Fluid) -> double
entity.insert_fluid(fluid)
takes_table: falsetable_optional: falseInsert fluid into this entity. Fluidbox is chosen automatically.
fluid: Fluid — Fluid to insert.double — Amount of fluid actually inserted.LuaEntity.clear_fluid_inside()
entity.clear_fluid_inside()
takes_table: falsetable_optional: falseRemove all fluids from this entity.
LuaEntity.get_beam_source() -> BeamTarget?
entity.get_beam_source()
takes_table: falsetable_optional: falseGet the source of this beam.
BeamTarget?LuaEntity.set_beam_source(source: LuaEntity | MapPosition)
entity.set_beam_source(source)
takes_table: falsetable_optional: falseSet the source of this beam.
source: LuaEntity | MapPositionLuaEntity.get_beam_target() -> BeamTarget?
entity.get_beam_target()
takes_table: falsetable_optional: falseGet the target of this beam.
BeamTarget?LuaEntity.set_beam_target(target: LuaEntity | MapPosition)
entity.set_beam_target(target)
takes_table: falsetable_optional: falseSet the target of this beam.
target: LuaEntity | MapPositionLuaEntity.get_radius() -> double
entity.get_radius()
takes_table: falsetable_optional: falseThe radius of this entity. The radius is defined as half the distance between the top left corner and bottom right corner of the collision box.
doubleLuaEntity.get_health_ratio() -> float?
entity.get_health_ratio()
takes_table: falsetable_optional: falseThe health ratio of this entity between 1 and 0 (for full health and no health respectively).
float? — nil if this entity doesn't have health.LuaEntity.create_build_effect_smoke()
entity.create_build_effect_smoke()
takes_table: falsetable_optional: falseCreates 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}
LuaEntity.release_from_spawner()
entity.release_from_spawner()
takes_table: falsetable_optional: falseRelease the unit from the spawner which spawned it. This allows the spawner to continue spawning additional units.
LuaEntity.toggle_equipment_movement_bonus()
entity.toggle_equipment_movement_bonus()
takes_table: falsetable_optional: falseToggle this entity's equipment movement bonus. Does nothing if the entity does not have an equipment grid.
This property can also be read and written on the equipment grid of this entity.
LuaEntity.can_shoot(target: LuaEntity, position: MapPosition) -> boolean
entity.can_shoot(target, position)
takes_table: falsetable_optional: falseWhether this character can shoot the given entity or position.
target: LuaEntityposition: MapPositionbooleanLuaEntity.start_fading_out()
entity.start_fading_out()
takes_table: falsetable_optional: falseOnly 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.
LuaEntity.get_upgrade_target() -> LuaEntityPrototype?, LuaQualityPrototype?
entity.get_upgrade_target()
takes_table: falsetable_optional: falseReturns the new entity prototype and its quality.
LuaEntityPrototype? — nil if this entity is not marked for upgrade.LuaQualityPrototype? — nil if this entity is not marked for upgrade.LuaEntity.get_damage_to_be_taken() -> float?
entity.get_damage_to_be_taken()
takes_table: falsetable_optional: falseReturns the amount of damage to be taken by this entity.
float? — nil if this entity does not have health.LuaEntity.deplete()
entity.deplete()
takes_table: falsetable_optional: falseDepletes and destroys this resource entity.
LuaEntity.mine{ inventory?: LuaInventory, force?: boolean, raise_destroyed?: boolean, ignore_minable?: boolean } -> boolean
entity.mine{ raise_destroyed=true }
takes_table: truetable_optional: trueMines this entity.
'Standard' operation is to keep calling LuaEntity.mine with an inventory until all items are transferred and the items dealt with.
The result of mining the entity (the item(s) it produces when mined) will be dropped on the ground if they don't fit into the provided inventory. If no inventory is provided, the items will be destroyed.
inventory?: LuaInventory — If provided the item(s) will be transferred into this inventory. If provided, this must be an inventory created with LuaGameScript::create_inventory or be a basic inventory owned by some entity.force?: boolean — If true, when the item(s) don't fit into the given inventory the entity is force mined. If false, the mining operation fails when there isn't enough room to transfer all of the items into the inventory. Defaults to false. This is ignored and acts as true if no inventory is provided.raise_destroyed?: boolean — If true, script_raised_destroy will be raised. Defaults to true.ignore_minable?: boolean — If true, the minable state of the entity is ignored. Defaults to false. If false, an entity that isn't minable (set as not-minable in the prototype or isn't minable for other reasons) will fail to be mined.boolean — Whether mining succeeded.LuaEntity.spawn_decorations()
entity.spawn_decorations()
takes_table: falsetable_optional: falseTriggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or "unit-spawner".
LuaEntity.get_priority_target(index: uint32) -> LuaEntityPrototype?
entity.get_priority_target(index)
takes_table: falsetable_optional: falseGet the entity ID at the specified position in the turret's priority list.
index: uint32 — The index of the entry to fetch.LuaEntityPrototype?LuaEntity.set_priority_target(index: uint32, entity_id?: EntityID)
entity.set_priority_target(index, entity_id)
takes_table: falsetable_optional: falseSet the entity ID name at the specified position in the turret's priority list.
index: uint32 — The index of the entry to set.entity_id?: EntityID — The name of the entity prototype, or nil to clear the entry.LuaEntity.can_wires_reach(entity: LuaEntity) -> boolean
entity.can_wires_reach(entity)
takes_table: falsetable_optional: falseCan wires reach between these entities.
entity: LuaEntitybooleanLuaEntity.get_connected_rolling_stock(direction: defines.rail_direction) -> LuaEntity?, defines.rail_direction?
entity.get_connected_rolling_stock(direction)
takes_table: falsetable_optional: falseGets rolling stock connected to the given end of this stock.
direction: defines.rail_directionLuaEntity? — The rolling stock connected at the given end, nil if none is connected there.defines.rail_direction? — The rail direction of the connected rolling stock if any.LuaEntity.is_registered_for_construction() -> boolean
entity.is_registered_for_construction()
takes_table: falsetable_optional: falseIs 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.
booleanLuaEntity.is_registered_for_deconstruction(force: ForceID) -> boolean
entity.is_registered_for_deconstruction(force)
takes_table: falsetable_optional: falseIs this entity registered for deconstruction with this force? If false, it means a construction robot has been dispatched to deconstruct it, or it is not marked for deconstruction. The complexity is effectively O(1) - it depends on the number of objects targeting this entity which should be small enough.
force: ForceID — The force construction manager to check.booleanLuaEntity.is_registered_for_upgrade() -> boolean
entity.is_registered_for_upgrade()
takes_table: falsetable_optional: falseIs 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.
booleanLuaEntity.is_registered_for_repair() -> boolean
entity.is_registered_for_repair()
takes_table: falsetable_optional: falseIs this entity registered for repair? If false, it means a construction robot has been dispatched to repair 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.
booleanLuaEntity.add_autopilot_destination(position: MapPosition)
entity.add_autopilot_destination(position)
takes_table: falsetable_optional: falseAdds the given position to this spidertron's autopilot's queue of destinations.
position: MapPosition — The position the spidertron should move to.LuaEntity.connect_linked_belts(neighbour?: LuaEntity)
entity.connect_linked_belts()
takes_table: falsetable_optional: falseConnects 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.
neighbour?: LuaEntity — Another linked belt or entity ghost containing linked belt to connect or nil to disconnectLuaEntity.disconnect_linked_belts()
entity.disconnect_linked_belts()
takes_table: falsetable_optional: falseDisconnects linked belt from its neighbour.
LuaEntity.get_spider_legs() -> Array<LuaEntity>
entity.get_spider_legs()
takes_table: falsetable_optional: falseGets legs of given SpiderVehicle.
Array<LuaEntity>LuaEntity.stop_spider()
entity.stop_spider()
takes_table: falsetable_optional: falseSets the speed of the given SpiderVehicle to zero. Notably does not clear its autopilot_destination, which it will continue moving towards if set.
LuaEntity.get_wire_connector(wire_connector_id: defines.wire_connector_id, or_create: boolean) -> LuaWireConnector
entity.get_wire_connector(wire_connector_id, true)
takes_table: falsetable_optional: falseGets a single wire connector of this entity
wire_connector_id: defines.wire_connector_id — Identifier of a specific connector to getor_create: boolean — If true and connector does not exist, it will be allocated if possibleLuaWireConnectorLuaEntity.get_wire_connectors(or_create: boolean) -> Dict<defines.wire_connector_id, LuaWireConnector>
entity.get_wire_connectors(true)
takes_table: falsetable_optional: falseGets all wire connectors of this entity
or_create: boolean — If true, it will try to create all connectors possibleDict<defines.wire_connector_id, LuaWireConnector>LuaEntity.get_rail_end(direction: defines.rail_direction) -> LuaRailEnd
entity.get_rail_end(direction)
takes_table: falsetable_optional: falseGets a LuaRailEnd object for specified end of this rail
direction: defines.rail_directionLuaRailEndLuaEntity.get_electric_input_flow_limit(quality?: QualityID) -> double?
entity.get_electric_input_flow_limit()
takes_table: falsetable_optional: falseThe input flow limit for the electric energy source. nil if the entity doesn't have an electric energy source.
quality?: QualityIDdouble?LuaEntity.get_electric_output_flow_limit(quality?: QualityID) -> double?
entity.get_electric_output_flow_limit()
takes_table: falsetable_optional: falseThe output flow limit for the electric energy source. nil if the entity doesn't have an electric energy source.
quality?: QualityIDdouble?LuaEntity.get_beacons() -> Array<LuaEntity>?
entity.get_beacons()
takes_table: falsetable_optional: falseReturns a table with all beacons affecting this effect receiver. Can only be used when the entity has an effect receiver (AssemblingMachine, Furnace, Lab, MiningDrills)
Array<LuaEntity>?LuaEntity.get_beacon_effect_receivers() -> Array<LuaEntity>
entity.get_beacon_effect_receivers()
takes_table: falsetable_optional: falseReturns a table with all entities affected by this beacon
Array<LuaEntity>LuaEntity.force_finish_ascending()
entity.force_finish_ascending()
takes_table: falsetable_optional: falseTake an ascending cargo pod and safely make it skip all animation and immediately switch surface.
LuaEntity.force_finish_descending()
entity.force_finish_descending()
takes_table: falsetable_optional: falseTake a descending cargo pod and safely make it arrive and deposit cargo.
LuaEntity.create_cargo_pod(cargo_hatch?: LuaCargoHatch) -> LuaEntity?
entity.create_cargo_pod()
takes_table: falsetable_optional: falseCreates a cargo pod if possible.
Cargo pod will be created with invalid destination type. Setting cargo_pod_destination will cause it to launch.
cargo_hatch?: LuaCargoHatch — The hatch to create the pod at. A random (available) one is picked if not provided.LuaEntity?LuaEntity.get_cargo_bays() -> Array<LuaEntity>
entity.get_cargo_bays()
takes_table: falsetable_optional: falseGets the cargo bays connected to this cargo landing pad or space platform hub.
Array<LuaEntity>LuaEntity.inventory_supports_bar(inventory_index: defines.inventory) -> boolean
entity.inventory_supports_bar(inventory_index)
takes_table: falsetable_optional: falseThe same as LuaInventory::supports_bar but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventorybooleanLuaEntity.get_inventory_bar(inventory_index: defines.inventory) -> uint32
entity.get_inventory_bar(inventory_index)
takes_table: falsetable_optional: falseThe same as LuaInventory::get_bar but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventoryuint32LuaEntity.set_inventory_bar(inventory_index: defines.inventory, bar?: uint32)
entity.set_inventory_bar(inventory_index, bar)
takes_table: falsetable_optional: falseThe same as LuaInventory::set_bar but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventorybar?: uint32 — The new limit. Omitting this parameter or passing nil will clear the limit.LuaEntity.inventory_supports_filters(inventory_index: defines.inventory) -> boolean
entity.inventory_supports_filters(inventory_index)
takes_table: falsetable_optional: falseThe same as LuaInventory::supports_filters but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventorybooleanLuaEntity.is_inventory_filtered(inventory_index: defines.inventory) -> boolean
entity.is_inventory_filtered(inventory_index)
takes_table: falsetable_optional: falseThe same as LuaInventory::is_filtered but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventorybooleanLuaEntity.can_set_inventory_filter(inventory_index: defines.inventory, index: uint32, filter: ItemFilter) -> boolean
entity.can_set_inventory_filter(inventory_index, index, filter)
takes_table: falsetable_optional: falseThe same as LuaInventory::can_set_filter but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventoryindex: uint32 — The item stack indexfilter: ItemFilter — The item filterbooleanLuaEntity.get_inventory_filter(inventory_index: defines.inventory, index: uint32) -> ItemFilter?
entity.get_inventory_filter(inventory_index, index)
takes_table: falsetable_optional: falseThe same as LuaInventory::get_filter but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventoryindex: uint32 — The item stack indexItemFilter? — The current filter or nil if none.LuaEntity.set_inventory_filter(inventory_index: defines.inventory, index: uint32, filter: ItemFilter | nil) -> boolean
entity.set_inventory_filter(inventory_index, index, filter)
takes_table: falsetable_optional: falseThe same as LuaInventory::set_filter but also works for ghosts where the inventory is not available through LuaControl::get_inventory.
inventory_index: defines.inventoryindex: uint32 — The item stack index.filter: ItemFilter | nil — The new filter. nil erases any existing filter.boolean — If the filter was allowed to be set.LuaEntity.register_tree(tree: LuaEntity) -> boolean
entity.register_tree(tree)
takes_table: falsetable_optional: falseRegisters the given tree in this agricultural tower.
If the tree is not within range of the tower it will not be registered.
If the tree is already registered with a tower it will not be registered.
tree: LuaEntityboolean — If the tree was registered.LuaEntity.get_movement() -> Vector
entity.get_movement()
takes_table: falsetable_optional: falseGets the combined movement vector (direction and speed) of this combat robot or asteroid. The entity moves by this vector each tick.
Note that for combat robots this does not include the constant drift in the direction they are facing.
VectorLuaEntity.set_movement(direction: Vector, speed: double)
entity.set_movement(direction, speed)
takes_table: falsetable_optional: falseSets the movement direction and movement speed for this combat robot or asteroid.
Note that for combat robots this does not affect the constant drift in the direction they are facing.
direction: Vector — This normalized form of this vector is used for the movement direction.speed: double — Speed in tiles per tick. Cannot be less than 0.LuaEntity.get_fluid(index: uint32) -> Fluid?
entity.get_fluid(index)
takes_table: falsetable_optional: falseGets fluid of the index-th fluid storage. This includes fluidbox and non-fluidbox fluid storages like fluid wagon contents. Refer to LuaEntity::fluids_count for more information on available storages.
index: uint32 — Fluid storage index. Valid values are from 1 up to LuaEntity::fluids_count.Fluid? — Fluid in this storage. nil if fluid storage is empty.LuaEntity.set_fluid(index: uint32, fluid?: Fluid) -> Fluid?
entity.set_fluid(index, fluid)
takes_table: falsetable_optional: falseSets fluid to the index-th fluid storage. This includes fluidbox and non-fluidbox fluid storages like fluid wagon contents. Refer to LuaEntity::fluids_count for more information on available storages.
Fluid storages that are part of fluidboxes (also available through LuaFluidBox) may reject some fluids if they do not match filters or are above the fluidbox volume. To verify how much fluid was set a return value can be used which is the same as value that would be returned by LuaEntity::get_fluid.
index: uint32 — Fluid storage index. Valid values are from 1 up to LuaEntity::fluids_count.fluid?: Fluid — Fluid to set. Fluid storage will be cleared if this is not provided.Fluid? — Fluid in this storage after it was set. nil if fluid storage is empty.LuaEntity.get_logistic_sections() -> LuaLogisticSections?
entity.get_logistic_sections()
takes_table: falsetable_optional: falseGives logistic sections of this entity if it uses logistic sections.
LuaLogisticSections?LuaEntity.set_inventory_size_override(inventory_index: defines.inventory, size_override: uint16 | nil, overflow?: LuaInventory)
entity.set_inventory_size_override(inventory_index, size_override, overflow)
takes_table: falsetable_optional: falseSets inventory size override. When set, supported entity will ignore inventory size from prototype and will instead keep inventory size equal to the override. Setting nil will restore default inventory size.
inventory_index: defines.inventorysize_override: uint16 | niloverflow?: LuaInventory — Items that would be deleted due to change of inventory size will be transferred to this inventory. Must be a script inventory or inventory of other entity. Inventory references obtained from proxy container are not allowed.LuaEntity.get_inventory_size_override(inventory_index: defines.inventory) -> uint16?
entity.get_inventory_size_override(inventory_index)
takes_table: falsetable_optional: falseGets the inventory size override of the selected inventory if size override was set using set_inventory_size_override.
inventory_index: defines.inventoryuint16?LuaEntity.get_fluid_source_tile() -> TilePosition
entity.get_fluid_source_tile()
takes_table: falsetable_optional: falseGives TilePosition of a tile which this offshore pump uses to check what fluid should be produced.
TilePositionLuaEntity.get_fluid_source_fluid() -> string?
entity.get_fluid_source_fluid()
takes_table: falsetable_optional: falseChecks what is expected fluid to be produced from the offshore pump's source tile. It accounts for visible tile, hidden tile and double hidden tile. It ignores currently set fluid box filter.
string? — Name of fluid that should be produced by this offshore pump based on existing tiles.