Home

LuaEntity

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.

Parent

Attributes

rail_length

Length of this rail piece.

name

Name of the entity prototype. E.g. "inserter" or "fast-inserter".

ghost_name

Name of the entity or tile contained in this ghost.

localised_name

Localised name of the entity.

localised_description

ghost_localised_name

Localised name of the entity or tile contained in this ghost.

ghost_localised_description

type

The entity prototype type of this entity.

ghost_type

The prototype type of the entity or tile contained in this ghost.

use_filters

If set to 'true', this inserter will use filtering logic.

This has no effect if the prototype does not support filters.

active

Deactivating 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.

destructible

If 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.

minable

Not 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.

minable_flag

Script controlled flag that allows entity to be mined.

rotatable

When 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.

operable

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

The 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.

max_health

Max health of this entity.

direction

The current direction this entity is facing.

mirroring

Whether 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.

supports_direction

Whether the entity has direction. When it is false for this entity, it will always return north direction when asked for.

orientation

The smooth orientation of this entity. For turrets this is the orientation of the weapon.

cliff_orientation

The orientation of this cliff.

relative_turret_orientation

The 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.

torso_orientation

The torso orientation of this spider vehicle.

amount

Count of resource units contained.

initial_amount

Count 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.

effectivity_modifier

Multiplies the acceleration the car can create for one unit of energy. Defaults to 1.

consumption_modifier

Multiplies the energy consumption.

friction_modifier

Multiplies the car friction rate.

driver_is_gunner

Whether 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.

vehicle_automatic_targeting_parameters

Read when this spidertron auto-targets enemies

speed

The 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.

effective_speed

The current speed of this unit in tiles per tick, taking into account any walking speed modifier given by the tile the unit is standing on. nil if this is not a unit.

stack

prototype

The entity prototype of this entity.

ghost_prototype

The prototype of the entity or tile contained in this ghost.

drop_position

Position 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.

pickup_position

Where 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.

drop_target

The 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.

pickup_target

The 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.

selected_gun_index

Index of the currently selected weapon slot of this character, car, or spidertron. nil if this entity doesn't have guns.

energy

Energy 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.

temperature

The temperature of this entity's heat energy source. nil if this entity does not use a heat energy source.

previous_recipe

The previous recipe this furnace was using, if any.

held_stack

The item stack currently held in an inserter's hand.

held_stack_position

Current position of the inserter's "hand".

train

The train this rolling stock belongs to, if any. nil if this is not a rolling stock.

neighbours

A list of neighbours for certain types of entities. Applies to underground belts, walls, gates, reactors, heat pipes, cliffs, and pipe-connectable entities.

belt_neighbours

The belt connectable neighbours of this belt connectable entity. Only entities that input to or are outputs of this entity. Does not contain the other end of an underground belt, see LuaEntity::neighbours for that.

heat_neighbours

The entities connected to this entities heat buffer.

fluidbox

Fluidboxes of this entity.

backer_name

The 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.

entity_label

The label on this spider-vehicle entity, if any. nil if this is not a spider-vehicle.

time_to_live

The ticks left before a combat robot, highlight box, smoke, or sticker entity is destroyed.

color

The 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.

signal_state

The state of this rail signal.

chain_signal_state

The state of this chain signal.

to_be_looted

Will this item entity be picked up automatically when the player walks over it?

crafting_speed

The current crafting speed, including speed bonuses from modules and beacons.

crafting_progress

The current crafting progress, as a number in range [0, 1].

bonus_progress

The current productivity bonus progress, as a number in range [0, 1].

result_quality

The quality produced when this crafting machine finishes crafting. nil when crafting is not in progress.

Note: Writing nil is not allowed.

productivity_bonus

The productivity bonus of this entity.

This includes force based bonuses as well as beacon/module bonuses.

pollution_bonus

The pollution bonus of this entity.

speed_bonus

The speed bonus of this entity.

This includes force based bonuses as well as beacon/module bonuses.

consumption_bonus

The consumption bonus of this entity.

belt_to_ground_type

Whether this underground belt goes into or out of the ground.

loader_type

Whether this loader gets items from or puts item into a container.

use_transitional_requests

When 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.

transitional_request_target

The space platform in orbit this rocket silo is automatically requesting items for.

rocket_parts

Number of rocket parts in this rocket silo.

send_to_orbit_automatically

Whether this rocket silo is set to send items to orbit automatically. Only relevant if there is an item prototype with launch products with automated send_to_orbit_mode, such as the satellite in vanilla (without Space Age mod).

logistic_network

The logistic network this entity is a part of, or nil if this entity is not a part of any logistic network.

logistic_cell

The logistic cell this entity is a part of. Will be nil if this entity is not a part of any logistic cell.

item_requests

Items this ghost will request when revived or items this item request proxy is requesting.

insert_plan

The insert plan for this ghost or item request proxy.

removal_plan

The removal plan for this item request proxy.

player

The player connected to this character, if any.

damage_dealt

The damage dealt by this turret, artillery turret, or artillery wagon.

kills

The number of units killed by this turret, artillery turret, or artillery wagon.

ignore_unprioritised_targets

Whether this turret shoots at targets that are not on its priority list.

last_user

The 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.

electric_buffer_size

The 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.

electric_drain

The electric drain for the electric energy source. nil if the entity doesn't have an electric energy source.

electric_emissions_per_joule

The 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.

unit_number

A 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.

ghost_unit_number

The 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.

mining_progress

The 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.

bonus_mining_progress

The 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.

mining_area

Area in which this mining drill looks for resources to mine.

power_production

The power production specific to the ElectricEnergyInterface entity type.

power_usage

The power usage specific to the ElectricEnergyInterface entity type.

bounding_box

LuaEntityPrototype::collision_box around entity's given position and respecting the current entity orientation.

secondary_bounding_box

The 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.

selection_box

LuaEntityPrototype::selection_box around entity's given position and respecting the current entity orientation.

secondary_selection_box

The 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.

mining_target

The mining target, if any.

filter_slot_count

The number of filter slots this inserter, loader, mining drill, asteroid collector or logistic storage container has. 0 if not one of those entities.

loader_container

The container entity this loader is pointing at/pulling from depending on the LuaEntity::loader_type, if any.

grid

This entity's equipment grid, if any.

graphics_variation

The graphics variation for this entity. nil if this entity doesn't use graphics variations.

tree_color_index

Index of the tree color.

tree_color_index_max

Maximum index of the tree colors.

tree_stage_index

Index of the tree stage.

tree_stage_index_max

Maximum index of the tree stages.

tree_gray_stage_index

Index of the tree gray stage

tree_gray_stage_index_max

Maximum index of the tree gray stages.

burner

The burner energy source for this entity, if any.

shooting_target

The shooting target for this turret, if any. Can't be set to nil via script.

proxy_target

The target entity for this item-request-proxy, if any.

stickers

The sticker entities attached to this entity, if any.

sticked_to

The entity this sticker is sticked to.

sticker_vehicle_modifiers

The vehicle modifiers applied to this entity through the attached stickers.

parameters

alert_parameters

electric_network_statistics

The electric network statistics for this electric pole.

inserter_target_pickup_count

Returns the current target pickup count of the inserter.

This considers the circuit network, manual override and the inserter stack size limit based on technology.

inserter_stack_size_override

Sets the stack size limit on this inserter.

Set to 0 to reset.

products_finished

The number of products this machine finished crafting in its lifetime.

spawning_cooldown

absorbed_pollution

spawn_shift

units

The units associated with this spawner entity.

power_switch_state

The state of this power switch.

combinator_description

The description on this combinator.

effects

The effects being applied to this entity, if any. For beacons, this is the effect the beacon is broadcasting.

beacons_count

Number of beacons affecting this effect receiver. Can only be used when the entity has an effect receiver (AssemblingMachine, Furnace, Lab, MiningDrills)

infinity_container_filters

The filters for this infinity container.

remove_unfiltered_items

Whether items not included in this infinity container filters should be removed from the container.

character_corpse_player_index

The 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.

character_corpse_tick_of_death

The tick this character corpse died at.

character_corpse_death_cause

The reason this character corpse character died. "" if there is no reason.

associated_player

The 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.

tick_of_last_attack

The last tick this character entity was attacked.

tick_of_last_damage

The last tick this character entity was damaged.

splitter_filter

The filter for this splitter, if any is set.

inserter_filter_mode

The filter mode for this filter inserter. nil if this inserter doesn't use filters.

loader_filter_mode

The filter mode for this loader. nil if this loader does not support filters.

loader_belt_stack_size_override

The belt stack size override for this loader. Set to 0 to disable. Writing this value requires LoaderPrototype::adjustable_belt_stack_size to be true.

mining_drill_filter_mode

The filter mode for this mining drill. nil if this mining drill doesn't have filters.

splitter_input_priority

The input priority for this splitter.

splitter_output_priority

The output priority for this splitter.

inserter_spoil_priority

The spoil priority for this inserter.

armed

Whether this land mine is armed.

recipe_locked

When locked; the recipe in this assembling machine can't be changed by the player.

connected_rail

The rail entity this train stop is connected to, if any.

connected_rail_direction

Rail direction to which this train stop is binding. This returns a value even when no rails are present.

trains_in_block

The number of trains in this rail block for this rail entity.

timeout

The timeout that's left on this landmine in ticks. It describes the time between the landmine being placed and it being armed.

neighbour_bonus

The current total neighbour bonus of this reactor.

ai_settings

The ai settings of this unit.

highlight_box_type

The highlight box type of this highlight box entity.

highlight_box_blink_interval

The blink interval of this highlight box entity. 0 indicates no blink.

status

The status of this entity, if any.

This is always the actual status of the entity, even if LuaEntity::custom_status is set.

custom_status

A custom status for this entity that will be displayed in the GUI.

enable_logistics_while_moving

Whether equipment grid logistics are enabled while this vehicle is moving.

render_player

The 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.

render_to_forces

The 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.

pump_rail_target

The rail target of this pump, if any.

valve_threshold_override

The 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.

electric_network_id

Returns the id of the electric network that this entity is connected to, if any.

allow_dispatching_robots

Whether this character's personal roboports are allowed to dispatch robots.

energy_generated_last_tick

How much energy this generator generated in the last tick.

storage_filter

The storage filter for this logistic storage container.

Useable only on logistic containers with the "storage" logistic_mode.

request_from_buffers

Whether this requester chest is set to also request from buffer chests.

Useable only on entities that have requester slots.

corpse_expires

Whether this corpse will ever fade away.

corpse_immune_to_entity_placement

If true, corpse won't be destroyed when entities are placed over it. If false, whether corpse will be removed or not depends on value of CorpsePrototype::remove_on_entity_placement.

tags

The tags associated with this entity ghost. nil if this is not an entity ghost or when the ghost has no tags.

time_to_next_effect

The ticks until the next trigger effect of this smoke-with-trigger.

autopilot_destination

Destination of this spidertron's autopilot, if any. Writing nil clears all destinations.

autopilot_destinations

The queued destination positions of spidertron's autopilot.

trains_count

Amount of trains related to this particular train stop. Includes train stopped at this train stop (until it finds a path to next target) and trains having this train stop as goal or waypoint.

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.

trains_limit

Amount 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.

is_military_target

Whether this entity is a MilitaryTarget. Can be written to if LuaEntityPrototype::allow_run_time_change_of_is_military_target returns true.

is_entity_with_owner

If this entity is EntityWithOwner

is_entity_with_health

If this entity is EntityWithHealth

combat_robot_owner

The owner of this combat robot, if any.

link_id

The link ID this linked container is using.

follow_target

The follow target of this spidertron, if any.

follow_offset

The follow offset of this spidertron, if any entity is being followed. This is randomized each time the follow entity is set.

linked_belt_type

Type 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).

linked_belt_neighbour

Neighbour to which this linked belt is connected to, if any.

May return entity ghost which contains linked belt to which connection is made.

quality

The quality of this entity.

Not all entities support quality and will give the "normal" quality back if they don't.

rail_layer

Gets rail layer of a given signal

radar_scan_progress

The current radar scan progress, as a number in range [0, 1].

name_tag

Name 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.

rocket_silo_status

The status of this rocket silo entity.

tile_width

Specifies 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.

tile_height

Specifies 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.

crane_end_position_3d

Returns current position in 3D for the end of the crane of this entity.

crane_destination

Destination of the crane of this entity. Throws when trying to set the destination out of range.

crane_destination_3d

Destination of the crane of this entity in 3D. Throws when trying to set the destination out of range.

crane_grappler_destination

Will 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.

crane_grappler_destination_3d

Will 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.

owned_plants

Plants registered by this agricultural tower. One plant can be registered in multiple agricultural towers.

copy_color_from_train_stop

If this rolling stock has 'copy color from train stop' enabled.

is_headed_to_trains_front

If the rolling stock is facing train's front.

draw_data

Gives a draw data of the given entity if it supports such data.

train_stop_priority

Priority of this train stop.

belt_shape

Gives what is the current shape of a transport-belt.

gps_tag

Returns 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.

commandable

Returns a LuaCommandable for this entity or nil if entity is not commandable. Units and SpiderUnits are commandable.

fluids_count

Returns 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.

tick_grown

The tick when this plant is fully grown.

always_on

If the lamp is always on when not driven by control behavior.

artillery_auto_targeting

If this artillery auto-targets enemies.

robot_order_queue

Get the current queue of robot orders.

procession_tick

how far into the current procession the cargo pod is.

is_updatable

Whether the entity is updatable and considered an UpdatableEntity.

disabled_by_script

If 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.

disabled_by_control_behavior

If the updatable entity is disabled by control behavior.

Always returns false if this entity is not considered updatable.

disabled_by_recipe

If 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.

is_freezable

Whether the entity is freezable and considered a FreezableEntity.

frozen

Whether the freezable entity is currently frozen.

Always returns false if this entity is not considered freezable.

cargo_hatches

The cargo hatches owned by this entity if any.

cargo_pod_state

The state of this cargo pod entity.

cargo_pod_destination

The destination of this cargo pod entity.

Use force_finish_ascending if you want it to only descend from orbit.

cargo_pod_origin

The origin of this cargo pod entity. (Must be a silo, hub or pad)

attached_cargo_pod

The cargo pod attached to this rocket silo rocket if any.

rocket

The rocket silo rocket this cargo pod is attached to, or rocket silo rocket attached to this rocket silo - if any.

item_request_proxy

The first found item request proxy targeting this entity.

base_damage_modifiers

bonus_damage_modifiers

cargo_bay_connection_owner

The space platform hub or cargo landing pad this cargo bay is connected to if any.

pickup_from_left_lane

For inserters taking items from transport belt connectables, this determines whether the inserter is allowed to take items from the left lane.

pickup_from_right_lane

For inserters taking items from transport belt connectables, this determines whether the inserter is allowed to take items from the right lane.

segmented_unit

The segmented unit object that the segment entity is a part of.

pumped_last_tick

The amount of fluid moved by this offshore pump or normal pump in the last tick.

created_by_corpse

The corpse that caused this entity ghost to be created, if any.

priority_targets

The priority targets for this turret (if any).

proxy_target_entity

Entity of which inventory is exposed by this ProxyContainer

proxy_target_inventory

Inventory index of the inventory that is exposed by this ProxyContainer

display_panel_text

Text visible on the display panel. Can be written only when it is not set by control behavior.

display_panel_icon

Icon visible on the display panel. Can be written only when it is not set by control behavior.

display_panel_always_show

display_panel_show_in_chart

valid

Is 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.

object_name

The 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.

Methods

get_output_inventory

LuaEntity.get_output_inventory() -> LuaInventory?

Call As

entity.get_output_inventory()

Call Convention

Gets the entity's output inventory if it has one.

Returns

get_module_inventory

LuaEntity.get_module_inventory() -> LuaInventory?

Call As

entity.get_module_inventory()

Call Convention

Inventory for storing modules of this entity; nil if this entity has no module inventory.

Returns

get_fuel_inventory

LuaEntity.get_fuel_inventory() -> LuaInventory?

Call As

entity.get_fuel_inventory()

Call Convention

The fuel inventory for this entity or nil if this entity doesn't have a fuel inventory.

Returns

get_burnt_result_inventory

LuaEntity.get_burnt_result_inventory() -> LuaInventory?

Call As

entity.get_burnt_result_inventory()

Call Convention

The burnt result inventory for this entity or nil if this entity doesn't have a burnt result inventory.

Returns

damage

LuaEntity.damage(damage: float, force: ForceID, type?: DamageTypeID, source?: LuaEntity, cause?: LuaEntity) -> float

Call As

entity.damage(damage, force, type)

Call Convention

Damages the entity.

Parameters

Returns

can_be_destroyed

LuaEntity.can_be_destroyed() -> boolean

Call As

entity.can_be_destroyed()

Call Convention

Whether the entity can be destroyed

Returns

destroy

LuaEntity.destroy{ do_cliff_correction?: boolean, raise_destroy?: boolean, player?: PlayerIdentification, undo_index?: uint32 } -> boolean

Call As

entity.destroy{ raise_destroy=true }

Call Convention

Destroys the entity.

Not all entities can be destroyed - things such as rails under trains cannot be destroyed until the train is moved or destroyed.

Parameters

Returns

die

LuaEntity.die(force?: ForceID, cause?: LuaEntity) -> boolean

Call As

entity.die()

Call Convention

Immediately kills the entity. Does nothing if the entity doesn't have health.

Unlike LuaEntity::destroy, die will trigger the on_entity_died event and the entity will produce a corpse and drop loot if it has any.

Parameters

Returns

has_flag

LuaEntity.has_flag(flag: EntityPrototypeFlag) -> boolean

Call As

entity.has_flag(flag)

Call Convention

Test whether this entity's prototype has a certain flag set.

entity.has_flag(f) is a shortcut for entity.prototype.has_flag(f).

Parameters

Returns

ghost_has_flag

LuaEntity.ghost_has_flag(flag: EntityPrototypeFlag) -> boolean

Call As

entity.ghost_has_flag(flag)

Call Convention

Same as LuaEntity::has_flag, but targets the inner entity on a entity ghost.

Parameters

Returns

add_market_item

LuaEntity.add_market_item(offer: Offer)

Call As

entity.add_market_item(offer)

Call Convention

Offer a thing on the market.

Parameters

remove_market_item

LuaEntity.remove_market_item(offer: uint32) -> boolean

Call As

entity.remove_market_item(offer)

Call Convention

Remove 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.

Parameters

Returns

get_market_items

LuaEntity.get_market_items() -> Array<Offer>

Call As

entity.get_market_items()

Call Convention

Get all offers in a market as an array.

Returns

clear_market_items

LuaEntity.clear_market_items()

Call As

entity.clear_market_items()

Call Convention

Removes all offers from a market.

order_deconstruction

LuaEntity.order_deconstruction(force: ForceID, player?: PlayerIdentification, undo_index?: uint32) -> boolean

Call As

entity.order_deconstruction(force, player)

Call Convention

Sets the entity to be deconstructed by construction robots.

Parameters

Returns

cancel_deconstruction

LuaEntity.cancel_deconstruction(force: ForceID, player?: PlayerIdentification)

Call As

entity.cancel_deconstruction(force, player)

Call Convention

Cancels deconstruction if it is scheduled, does nothing otherwise.

Parameters

to_be_deconstructed

LuaEntity.to_be_deconstructed() -> boolean

Call As

entity.to_be_deconstructed()

Call Convention

Is this entity marked for deconstruction?

Returns

order_upgrade

LuaEntity.order_upgrade{ target: EntityWithQualityID, force: ForceID, player?: PlayerIdentification, undo_index?: uint32 } -> boolean

Call As

entity.order_upgrade{ target=target, force=force }

Call Convention

Sets the entity to be upgraded by construction robots.

Parameters

Returns

cancel_upgrade

LuaEntity.cancel_upgrade(force: ForceID, player?: PlayerIdentification) -> boolean

Call As

entity.cancel_upgrade(force, player)

Call Convention

Cancels upgrade if it is scheduled, does nothing otherwise.

Parameters

Returns

to_be_upgraded

LuaEntity.to_be_upgraded() -> boolean

Call As

entity.to_be_upgraded()

Call Convention

Is this entity marked for upgrade?

Returns

apply_upgrade

LuaEntity.apply_upgrade() -> LuaEntity?, LuaEntity?

Call As

entity.apply_upgrade()

Call Convention

Upgrades this entity in place if it's marked to be upgraded.

Returns

is_crafting

LuaEntity.is_crafting() -> boolean

Call As

entity.is_crafting()

Call Convention

Returns 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.

Returns

is_opened

LuaEntity.is_opened() -> boolean

Call As

entity.is_opened()

Call Convention

Returns

is_opening

LuaEntity.is_opening() -> boolean

Call As

entity.is_opening()

Call Convention

Returns

is_closed

LuaEntity.is_closed() -> boolean

Call As

entity.is_closed()

Call Convention

Returns

is_closing

LuaEntity.is_closing() -> boolean

Call As

entity.is_closing()

Call Convention

Returns

request_to_open

LuaEntity.request_to_open(force: ForceID, extra_time?: uint32)

Call As

entity.request_to_open(force, extra_time)

Call Convention

Parameters

request_to_close

LuaEntity.request_to_close(force: ForceID)

Call As

entity.request_to_close(force)

Call Convention

Parameters

get_transport_line

LuaEntity.get_transport_line(index: defines.transport_line) -> LuaTransportLine

Call As

entity.get_transport_line(index)

Call Convention

Get a transport line of a belt or belt connectable entity.

Parameters

Returns

get_item_insert_specification

LuaEntity.get_item_insert_specification(position: MapPosition) -> uint32, float

Call As

entity.get_item_insert_specification(position)

Call Convention

Get 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.

Parameters

Returns

get_line_item_position

LuaEntity.get_line_item_position(index: defines.transport_line, position: float) -> MapPosition

Call As

entity.get_line_item_position(index, position)

Call Convention

Get a map position related to a position on a transport line.

Parameters

Returns

get_max_transport_line_index

LuaEntity.get_max_transport_line_index() -> defines.transport_line

Call As

entity.get_max_transport_line_index()

Call Convention

Get the maximum transport line index of a belt or belt connectable entity.

Returns

launch_rocket

LuaEntity.launch_rocket(destination?: CargoDestination, character?: LuaEntity) -> boolean

Call As

entity.launch_rocket()

Call Convention

Parameters

Returns

revive

LuaEntity.revive{ raise_revive?: boolean, overflow?: LuaInventory } -> Dict<string, uint32>?, LuaEntity?, LuaEntity?

Call As

entity.revive{ raise_revive=true }

Call Convention

Revive a ghost, which turns it from a ghost into a real entity or tile.

Parameters

Returns

silent_revive

LuaEntity.silent_revive{ raise_revive?: boolean, overflow?: LuaInventory } -> ItemWithQualityCounts, LuaEntity?, LuaEntity?

Call As

entity.silent_revive{ raise_revive=true }

Call Convention

Revives a ghost silently, so the revival makes no sound and no smoke is created.

Parameters

Returns

get_connected_rail

LuaEntity.get_connected_rail{ rail_direction: defines.rail_direction, rail_connection_direction: defines.rail_connection_direction } -> LuaEntity?, defines.rail_direction?, defines.rail_connection_direction?

Call As

entity.get_connected_rail{ rail_direction=rail_direction, rail_connection_direction=rail_connection_direction }

Call Convention

Parameters

Returns

get_connected_rails

LuaEntity.get_connected_rails() -> Array<LuaEntity>

Call As

entity.get_connected_rails()

Call Convention

Get the rails that this signal is connected to.

Returns

get_rail_segment_signal

LuaEntity.get_rail_segment_signal(direction: defines.rail_direction, in_else_out: boolean) -> LuaEntity?

Call As

entity.get_rail_segment_signal(direction, true)

Call Convention

Get 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.

Parameters

Returns

get_rail_segment_stop

LuaEntity.get_rail_segment_stop(direction: defines.rail_direction) -> LuaEntity?

Call As

entity.get_rail_segment_stop(direction)

Call Convention

Get 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.

Parameters

Returns

get_rail_segment_end

LuaEntity.get_rail_segment_end(direction: defines.rail_direction) -> LuaEntity, defines.rail_direction

Call As

entity.get_rail_segment_end(direction)

Call Convention

Get 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.

Parameters

Returns

get_rail_segment_rails

LuaEntity.get_rail_segment_rails(direction: defines.rail_direction) -> Array<LuaEntity>

Call As

entity.get_rail_segment_rails(direction)

Call Convention

Get 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.

Parameters

Returns

get_rail_segment_length

LuaEntity.get_rail_segment_length() -> double

Call As

entity.get_rail_segment_length()

Call Convention

Get 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.

Returns

get_rail_segment_overlaps

LuaEntity.get_rail_segment_overlaps() -> Array<LuaEntity>

Call As

entity.get_rail_segment_overlaps()

Call Convention

Get 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.

Returns

is_rail_in_same_rail_segment_as

LuaEntity.is_rail_in_same_rail_segment_as(other_rail: LuaEntity) -> boolean

Call As

entity.is_rail_in_same_rail_segment_as(other_rail)

Call Convention

Checks if this rail and other rail both belong to the same rail segment.

Parameters

Returns

is_rail_in_same_rail_block_as

LuaEntity.is_rail_in_same_rail_block_as(other_rail: LuaEntity) -> boolean

Call As

entity.is_rail_in_same_rail_block_as(other_rail)

Call Convention

Checks if this rail and other rail both belong to the same rail block.

Parameters

Returns

get_parent_signals

LuaEntity.get_parent_signals() -> Array<LuaEntity>

Call As

entity.get_parent_signals()

Call Convention

Returns 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.

Returns

get_child_signals

LuaEntity.get_child_signals() -> Array<LuaEntity>

Call As

entity.get_child_signals()

Call Convention

Returns 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.

Returns

get_inbound_signals

LuaEntity.get_inbound_signals() -> Array<LuaEntity>

Call As

entity.get_inbound_signals()

Call Convention

Returns all signals guarding entrance to a rail block this rail belongs to.

Returns

get_outbound_signals

LuaEntity.get_outbound_signals() -> Array<LuaEntity>

Call As

entity.get_outbound_signals()

Call Convention

Returns all signals guarding exit from a rail block this rail belongs to.

Returns

get_filter

LuaEntity.get_filter(slot_index: uint32) -> ItemFilter | EntityID | AsteroidChunkID?

Call As

entity.get_filter(slot_index)

Call Convention

Get the filter for a slot in an inserter, loader, mining drill, asteroid collector, or logistic storage container. The entity must allow filters.

Parameters

Returns

set_filter

LuaEntity.set_filter(index: uint32, filter?: ItemFilter | ItemWithQualityID | EntityID | AsteroidChunkID)

Call As

entity.set_filter(index, filter)

Call Convention

Set 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.

Parameters

get_infinity_container_filter

LuaEntity.get_infinity_container_filter(index: uint32) -> InfinityInventoryFilter?

Call As

entity.get_infinity_container_filter(index)

Call Convention

Gets the filter for this infinity container at the given index, or nil if the filter index doesn't exist or is empty.

Parameters

Returns

set_infinity_container_filter

LuaEntity.set_infinity_container_filter(index: uint32, filter: InfinityInventoryFilter | nil)

Call As

entity.set_infinity_container_filter(index, filter)

Call Convention

Sets the filter for this infinity container at the given index.

Parameters

get_infinity_pipe_filter

LuaEntity.get_infinity_pipe_filter() -> InfinityPipeFilter?

Call As

entity.get_infinity_pipe_filter()

Call Convention

Gets the filter for this infinity pipe, or nil if the filter is empty.

Returns

set_infinity_pipe_filter

LuaEntity.set_infinity_pipe_filter(filter: InfinityPipeFilter | nil)

Call As

entity.set_infinity_pipe_filter(filter)

Call Convention

Sets the filter for this infinity pipe.

Parameters

get_heat_setting

LuaEntity.get_heat_setting() -> HeatSetting

Call As

entity.get_heat_setting()

Call Convention

Gets the heat setting for this heat interface.

Returns

set_heat_setting

LuaEntity.set_heat_setting(filter: HeatSetting)

Call As

entity.set_heat_setting(filter)

Call Convention

Sets the heat setting for this heat interface.

Parameters

get_control_behavior

LuaEntity.get_control_behavior() -> LuaControlBehavior?

Call As

entity.get_control_behavior()

Call Convention

Gets the control behavior of the entity (if any).

Returns

get_or_create_control_behavior

LuaEntity.get_or_create_control_behavior() -> LuaControlBehavior?

Call As

entity.get_or_create_control_behavior()

Call Convention

Gets (and or creates if needed) the control behavior of the entity.

Returns

get_circuit_network

LuaEntity.get_circuit_network(wire_connector_id: defines.wire_connector_id) -> LuaCircuitNetwork?

Call As

entity.get_circuit_network(wire_connector_id)

Call Convention

Parameters

Returns

get_signal

LuaEntity.get_signal(signal: SignalID, wire_connector_id: defines.wire_connector_id, extra_wire_connector_id?: defines.wire_connector_id) -> int32

Call As

entity.get_signal(signal, wire_connector_id, extra_wire_connector_id)

Call Convention

Read a single signal from the selected wire connector

Parameters

Returns

get_signals

LuaEntity.get_signals(wire_connector_id: defines.wire_connector_id, extra_wire_connector_id?: defines.wire_connector_id) -> Array<Signal>?

Call As

entity.get_signals(wire_connector_id, extra_wire_connector_id)

Call Convention

Read all signals from the selected wire connector.

Parameters

Returns

supports_backer_name

LuaEntity.supports_backer_name() -> boolean

Call As

entity.supports_backer_name()

Call Convention

Whether this entity supports a backer name.

Returns

copy_settings

LuaEntity.copy_settings(entity: LuaEntity, by_player?: PlayerIdentification) -> ItemWithQualityCounts

Call As

entity.copy_settings(entity, by_player)

Call Convention

Copies settings from the given entity onto this entity.

Parameters

Returns

get_logistic_point

LuaEntity.get_logistic_point(index?: defines.logistic_member_index) -> LuaLogisticPoint | Array<LuaLogisticPoint>?

Call As

entity.get_logistic_point()

Call Convention

Gets all the LuaLogisticPoints that this entity owns. Optionally returns only the point specified by the index parameter.

Parameters

Returns

play_note

LuaEntity.play_note(instrument: uint32, note: uint32, stop_playing_sounds?: boolean) -> boolean

Call As

entity.play_note(instrument, note, true)

Call Convention

Plays a note with the given instrument and note.

Parameters

Returns

connect_rolling_stock

LuaEntity.connect_rolling_stock(direction: defines.rail_direction) -> boolean

Call As

entity.connect_rolling_stock(direction)

Call Convention

Connects the rolling stock in the given direction.

Parameters

Returns

disconnect_rolling_stock

LuaEntity.disconnect_rolling_stock(direction: defines.rail_direction) -> boolean

Call As

entity.disconnect_rolling_stock(direction)

Call Convention

Tries to disconnect this rolling stock in the given direction.

Parameters

Returns

update_connections

LuaEntity.update_connections()

Call As

entity.update_connections()

Call Convention

Reconnect loader, beacon, cliff and mining drill connections to entities that might have been teleported out or in by the script. The game doesn't do this automatically as we don't want to lose performance by checking this in normal games.

get_recipe

LuaEntity.get_recipe() -> LuaRecipe?, LuaQualityPrototype?

Call As

entity.get_recipe()

Call Convention

Current recipe being assembled by this machine, if any.

Returns

set_recipe

LuaEntity.set_recipe(recipe?: RecipeID, quality?: QualityID) -> ItemWithQualityCounts

Call As

entity.set_recipe()

Call Convention

Sets the given recipe in this assembly machine.

Parameters

Returns

rotate

LuaEntity.rotate{ reverse?: boolean, by_player?: PlayerIdentification } -> boolean

Call As

entity.rotate{ reverse=true }

Call Convention

Rotates this entity as if the player rotated it.

Parameters

Returns

get_driver

LuaEntity.get_driver() -> LuaEntity | LuaPlayer?

Call As

entity.get_driver()

Call Convention

Gets the driver of this vehicle if any.

Returns

set_driver

LuaEntity.set_driver(driver: LuaEntity | PlayerIdentification | nil)

Call As

entity.set_driver(driver)

Call Convention

Sets the driver of this vehicle.

This differs from LuaEntity::set_passenger in that the passenger can't drive the vehicle.

Parameters

get_passenger

LuaEntity.get_passenger() -> LuaEntity | LuaPlayer?

Call As

entity.get_passenger()

Call Convention

Gets 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.

Returns

set_passenger

LuaEntity.set_passenger(passenger: LuaEntity | PlayerIdentification | nil)

Call As

entity.set_passenger(passenger)

Call Convention

Sets the passenger of this car, spidertron, or cargo pod.

This differs from LuaEntity::get_driver in that the passenger can't drive the car.

Parameters

is_connected_to_electric_network

LuaEntity.is_connected_to_electric_network() -> boolean

Call As

entity.is_connected_to_electric_network()

Call Convention

Returns 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.

Returns

get_train_stop_trains

LuaEntity.get_train_stop_trains() -> Array<LuaTrain>

Call As

entity.get_train_stop_trains()

Call Convention

The trains scheduled to stop at this train stop.

Returns

get_stopped_train

LuaEntity.get_stopped_train() -> LuaTrain?

Call As

entity.get_stopped_train()

Call Convention

The train currently stopped at this train stop, if any.

Returns

clone

LuaEntity.clone{ position: MapPosition, surface?: LuaSurface, force?: ForceID, create_build_effect_smoke?: boolean } -> LuaEntity?

Call As

entity.clone{ position=position }

Call Convention

Clones this entity.

Parameters

Returns

get_fluid_count

LuaEntity.get_fluid_count(fluid?: string) -> double

Call As

entity.get_fluid_count()

Call Convention

Get the amount of all or some fluid in this entity.

If information about fluid temperatures is required, LuaEntity::fluidbox should be used instead.

Parameters

Returns

get_fluid_contents

LuaEntity.get_fluid_contents() -> Dict<string, FluidAmount>

Call As

entity.get_fluid_contents()

Call Convention

Get amounts of all fluids in this entity.

If information about fluid temperatures is required, LuaEntity::get_fluid or LuaEntity::fluidbox should be used instead.

Returns

remove_fluid

LuaEntity.remove_fluid{ name: string, amount: double, minimum_temperature?: double, maximum_temperature?: double, temperature?: double } -> double

Call As

entity.remove_fluid{ name=name, amount=amount }

Call Convention

Remove 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.

Parameters

Returns

insert_fluid

LuaEntity.insert_fluid(fluid: Fluid) -> double

Call As

entity.insert_fluid(fluid)

Call Convention

Insert fluid into this entity. Fluidbox is chosen automatically.

Parameters

Returns

clear_fluid_inside

LuaEntity.clear_fluid_inside()

Call As

entity.clear_fluid_inside()

Call Convention

Remove all fluids from this entity.

get_beam_source

LuaEntity.get_beam_source() -> BeamTarget?

Call As

entity.get_beam_source()

Call Convention

Get the source of this beam.

Returns

set_beam_source

LuaEntity.set_beam_source(source: LuaEntity | MapPosition)

Call As

entity.set_beam_source(source)

Call Convention

Set the source of this beam.

Parameters

get_beam_target

LuaEntity.get_beam_target() -> BeamTarget?

Call As

entity.get_beam_target()

Call Convention

Get the target of this beam.

Returns

set_beam_target

LuaEntity.set_beam_target(target: LuaEntity | MapPosition)

Call As

entity.set_beam_target(target)

Call Convention

Set the target of this beam.

Parameters

get_radius

LuaEntity.get_radius() -> double

Call As

entity.get_radius()

Call Convention

The 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.

Returns

get_health_ratio

LuaEntity.get_health_ratio() -> float?

Call As

entity.get_health_ratio()

Call Convention

The health ratio of this entity between 1 and 0 (for full health and no health respectively).

Returns

create_build_effect_smoke

LuaEntity.create_build_effect_smoke()

Call As

entity.create_build_effect_smoke()

Call Convention

Creates the same smoke that is created when you place a building by hand.

You can play the building sound to go with it by using LuaSurface::play_sound, eg: entity.surface.play_sound{path="entity-build/"..entity.prototype.name, position=entity.position}

release_from_spawner

LuaEntity.release_from_spawner()

Call As

entity.release_from_spawner()

Call Convention

Release the unit from the spawner which spawned it. This allows the spawner to continue spawning additional units.

toggle_equipment_movement_bonus

LuaEntity.toggle_equipment_movement_bonus()

Call As

entity.toggle_equipment_movement_bonus()

Call Convention

Toggle 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.

can_shoot

LuaEntity.can_shoot(target: LuaEntity, position: MapPosition) -> boolean

Call As

entity.can_shoot(target, position)

Call Convention

Whether this character can shoot the given entity or position.

Parameters

Returns

start_fading_out

LuaEntity.start_fading_out()

Call As

entity.start_fading_out()

Call Convention

Only works if the entity is a speech-bubble, with an "effect" defined in its wrapper_flow_style. Starts animating the opacity of the speech bubble towards zero, and destroys the entity when it hits zero.

get_upgrade_target

LuaEntity.get_upgrade_target() -> LuaEntityPrototype?, LuaQualityPrototype?

Call As

entity.get_upgrade_target()

Call Convention

Returns the new entity prototype and its quality.

Returns

get_damage_to_be_taken

LuaEntity.get_damage_to_be_taken() -> float?

Call As

entity.get_damage_to_be_taken()

Call Convention

Returns the amount of damage to be taken by this entity.

Returns

deplete

LuaEntity.deplete()

Call As

entity.deplete()

Call Convention

Depletes and destroys this resource entity.

mine

LuaEntity.mine{ inventory?: LuaInventory, force?: boolean, raise_destroyed?: boolean, ignore_minable?: boolean } -> boolean

Call As

entity.mine{ raise_destroyed=true }

Call Convention

Mines 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.

Parameters

Returns

spawn_decorations

LuaEntity.spawn_decorations()

Call As

entity.spawn_decorations()

Call Convention

Triggers spawn_decoration actions defined in the entity prototype or does nothing if entity is not "turret" or "unit-spawner".

get_priority_target

LuaEntity.get_priority_target(index: uint32) -> LuaEntityPrototype?

Call As

entity.get_priority_target(index)

Call Convention

Get the entity ID at the specified position in the turret's priority list.

Parameters

Returns

set_priority_target

LuaEntity.set_priority_target(index: uint32, entity_id?: EntityID)

Call As

entity.set_priority_target(index, entity_id)

Call Convention

Set the entity ID name at the specified position in the turret's priority list.

Parameters

can_wires_reach

LuaEntity.can_wires_reach(entity: LuaEntity) -> boolean

Call As

entity.can_wires_reach(entity)

Call Convention

Can wires reach between these entities.

Parameters

Returns

get_connected_rolling_stock

LuaEntity.get_connected_rolling_stock(direction: defines.rail_direction) -> LuaEntity?, defines.rail_direction?

Call As

entity.get_connected_rolling_stock(direction)

Call Convention

Gets rolling stock connected to the given end of this stock.

Parameters

Returns

is_registered_for_construction

LuaEntity.is_registered_for_construction() -> boolean

Call As

entity.is_registered_for_construction()

Call Convention

Is this entity or tile ghost or item request proxy registered for construction? If false, it means a construction robot has been dispatched to build the entity, or it is not an entity that can be constructed.

Returns

is_registered_for_deconstruction

LuaEntity.is_registered_for_deconstruction(force: ForceID) -> boolean

Call As

entity.is_registered_for_deconstruction(force)

Call Convention

Is this entity registered for deconstruction with this force? If false, it means a construction robot has been dispatched to deconstruct it, or it is not marked for deconstruction. The complexity is effectively O(1) - it depends on the number of objects targeting this entity which should be small enough.

Parameters

Returns

is_registered_for_upgrade

LuaEntity.is_registered_for_upgrade() -> boolean

Call As

entity.is_registered_for_upgrade()

Call Convention

Is this entity registered for upgrade? If false, it means a construction robot has been dispatched to upgrade it, or it is not marked for upgrade. This is worst-case O(N) complexity where N is the current number of things in the upgrade queue.

Returns

is_registered_for_repair

LuaEntity.is_registered_for_repair() -> boolean

Call As

entity.is_registered_for_repair()

Call Convention

Is 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.

Returns

add_autopilot_destination

LuaEntity.add_autopilot_destination(position: MapPosition)

Call As

entity.add_autopilot_destination(position)

Call Convention

Adds the given position to this spidertron's autopilot's queue of destinations.

Parameters

connect_linked_belts

LuaEntity.connect_linked_belts(neighbour?: LuaEntity)

Call As

entity.connect_linked_belts()

Call Convention

Connects current linked belt with another one.

Neighbours have to be of different type. If given linked belt is connected to something else it will be disconnected first. If provided neighbour is connected to something else it will also be disconnected first. Automatically updates neighbour to be connected back to this one.

Parameters

disconnect_linked_belts

LuaEntity.disconnect_linked_belts()

Call As

entity.disconnect_linked_belts()

Call Convention

Disconnects linked belt from its neighbour.

get_spider_legs

LuaEntity.get_spider_legs() -> Array<LuaEntity>

Call As

entity.get_spider_legs()

Call Convention

Gets legs of given SpiderVehicle.

Returns

stop_spider

LuaEntity.stop_spider()

Call As

entity.stop_spider()

Call Convention

Sets the speed of the given SpiderVehicle to zero. Notably does not clear its autopilot_destination, which it will continue moving towards if set.

get_wire_connector

LuaEntity.get_wire_connector(wire_connector_id: defines.wire_connector_id, or_create: boolean) -> LuaWireConnector?

Call As

entity.get_wire_connector(wire_connector_id, true)

Call Convention

Gets a single wire connector of this entity, if any.

Parameters

Returns

get_wire_connectors

LuaEntity.get_wire_connectors(or_create: boolean) -> Dict<defines.wire_connector_id, LuaWireConnector>

Call As

entity.get_wire_connectors(true)

Call Convention

Gets all wire connectors of this entity

Parameters

Returns

get_rail_end

LuaEntity.get_rail_end(direction: defines.rail_direction) -> LuaRailEnd

Call As

entity.get_rail_end(direction)

Call Convention

Gets a LuaRailEnd object for specified end of this rail

Parameters

Returns

get_electric_input_flow_limit

LuaEntity.get_electric_input_flow_limit(quality?: QualityID) -> double?

Call As

entity.get_electric_input_flow_limit()

Call Convention

The input flow limit for the electric energy source. nil if the entity doesn't have an electric energy source.

Parameters

Returns

get_electric_output_flow_limit

LuaEntity.get_electric_output_flow_limit(quality?: QualityID) -> double?

Call As

entity.get_electric_output_flow_limit()

Call Convention

The output flow limit for the electric energy source. nil if the entity doesn't have an electric energy source.

Parameters

Returns

get_beacons

LuaEntity.get_beacons() -> Array<LuaEntity>?

Call As

entity.get_beacons()

Call Convention

Returns a table with all beacons affecting this effect receiver. Can only be used when the entity has an effect receiver (AssemblingMachine, Furnace, Lab, MiningDrills)

Returns

get_beacon_effect_receivers

LuaEntity.get_beacon_effect_receivers() -> Array<LuaEntity>

Call As

entity.get_beacon_effect_receivers()

Call Convention

Returns a table with all entities affected by this beacon

Returns

force_finish_ascending

LuaEntity.force_finish_ascending()

Call As

entity.force_finish_ascending()

Call Convention

Take an ascending cargo pod and safely make it skip all animation and immediately switch surface.

force_finish_descending

LuaEntity.force_finish_descending()

Call As

entity.force_finish_descending()

Call Convention

Take a descending cargo pod and safely make it arrive and deposit cargo.

create_cargo_pod

LuaEntity.create_cargo_pod(cargo_hatch?: LuaCargoHatch) -> LuaEntity?

Call As

entity.create_cargo_pod()

Call Convention

Creates a cargo pod if possible.

Cargo pod will be created with invalid destination type. Setting cargo_pod_destination will cause it to launch.

Parameters

Returns

get_cargo_bays

LuaEntity.get_cargo_bays() -> Array<LuaEntity>

Call As

entity.get_cargo_bays()

Call Convention

Gets the cargo bays connected to this cargo landing pad or space platform hub.

Returns

inventory_supports_bar

LuaEntity.inventory_supports_bar(inventory_index: defines.inventory) -> boolean

Call As

entity.inventory_supports_bar(inventory_index)

Call Convention

The same as LuaInventory::supports_bar but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

get_inventory_bar

LuaEntity.get_inventory_bar(inventory_index: defines.inventory) -> uint32

Call As

entity.get_inventory_bar(inventory_index)

Call Convention

The same as LuaInventory::get_bar but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

set_inventory_bar

LuaEntity.set_inventory_bar(inventory_index: defines.inventory, bar?: uint32)

Call As

entity.set_inventory_bar(inventory_index, bar)

Call Convention

The same as LuaInventory::set_bar but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

inventory_supports_filters

LuaEntity.inventory_supports_filters(inventory_index: defines.inventory) -> boolean

Call As

entity.inventory_supports_filters(inventory_index)

Call Convention

The same as LuaInventory::supports_filters but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

is_inventory_filtered

LuaEntity.is_inventory_filtered(inventory_index: defines.inventory) -> boolean

Call As

entity.is_inventory_filtered(inventory_index)

Call Convention

The same as LuaInventory::is_filtered but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

can_set_inventory_filter

LuaEntity.can_set_inventory_filter(inventory_index: defines.inventory, index: uint32, filter: ItemFilter) -> boolean

Call As

entity.can_set_inventory_filter(inventory_index, index, filter)

Call Convention

The same as LuaInventory::can_set_filter but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

get_inventory_filter

LuaEntity.get_inventory_filter(inventory_index: defines.inventory, index: uint32) -> ItemFilter?

Call As

entity.get_inventory_filter(inventory_index, index)

Call Convention

The same as LuaInventory::get_filter but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

set_inventory_filter

LuaEntity.set_inventory_filter(inventory_index: defines.inventory, index: uint32, filter: ItemFilter | nil) -> boolean

Call As

entity.set_inventory_filter(inventory_index, index, filter)

Call Convention

The same as LuaInventory::set_filter but also works for ghosts where the inventory is not available through LuaControl::get_inventory.

Parameters

Returns

register_tree

LuaEntity.register_tree(tree: LuaEntity) -> boolean

Call As

entity.register_tree(tree)

Call Convention

Registers 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.

Parameters

Returns

get_movement

LuaEntity.get_movement() -> Vector

Call As

entity.get_movement()

Call Convention

Gets 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.

Returns

set_movement

LuaEntity.set_movement(direction: Vector, speed: double)

Call As

entity.set_movement(direction, speed)

Call Convention

Sets 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.

Parameters

get_fluid

LuaEntity.get_fluid(index: uint32) -> Fluid?

Call As

entity.get_fluid(index)

Call Convention

Gets 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.

Parameters

Returns

set_fluid

LuaEntity.set_fluid(index: uint32, fluid?: Fluid) -> Fluid?

Call As

entity.set_fluid(index, fluid)

Call Convention

Sets 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.

Parameters

Returns

get_logistic_sections

LuaEntity.get_logistic_sections() -> LuaLogisticSections?

Call As

entity.get_logistic_sections()

Call Convention

Gives logistic sections of this entity if it uses logistic sections.

Returns

set_inventory_size_override

LuaEntity.set_inventory_size_override(inventory_index: defines.inventory, size_override: uint16 | nil, overflow?: LuaInventory)

Call As

entity.set_inventory_size_override(inventory_index, size_override, overflow)

Call Convention

Sets 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.

Parameters

get_inventory_size_override

LuaEntity.get_inventory_size_override(inventory_index: defines.inventory) -> uint16?

Call As

entity.get_inventory_size_override(inventory_index)

Call Convention

Gets the inventory size override of the selected inventory if size override was set using set_inventory_size_override.

Parameters

Returns

get_fluid_source_tile

LuaEntity.get_fluid_source_tile() -> TilePosition

Call As

entity.get_fluid_source_tile()

Call Convention

Gives TilePosition of a tile which this offshore pump uses to check what fluid should be produced.

Returns

get_fluid_source_fluid

LuaEntity.get_fluid_source_fluid() -> string?

Call As

entity.get_fluid_source_fluid()

Call Convention

Checks 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.

Returns