Skip to main content

LuaEntity

Struct LuaEntity 

Source
pub struct LuaEntity;
Expand description

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.

Implementations§

Source§

impl LuaEntity

Source

pub fn build_distance(&self) -> u32

The build distance of this character or max uint when not a character or player connected to a character.

Source

pub fn cargo_pod(&self) -> LuaEntity

The cargo pod the player is currently sitting in or the cargo pod attached to this rocket silo.

Source

pub fn character_additional_mining_categories(&self) -> Vec<&str>

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_build_distance_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_crafting_speed_modifier(&self) -> f64

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_health_bonus(&self) -> f32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_inventory_slots_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_item_drop_distance_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_item_pickup_distance_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_loot_pickup_distance_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_maximum_following_robot_count_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_mining_progress(&self) -> f64

The current mining progress between 0 and 1 of this character, or 0 if they aren’t mining.

Source

pub fn character_mining_speed_modifier(&self) -> f64

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_reach_distance_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_resource_reach_distance_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_running_speed(&self) -> f64

The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.

Source

pub fn character_running_speed_modifier(&self) -> f64

Modifies the running speed of this character by the given value as a percentage. Setting the running modifier to 0.5 makes the character run 50% faster. The minimum value of -1 reduces the movement speed by 100%, resulting in a speed of 0.

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn character_trash_slot_count_bonus(&self) -> u32

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn cheat_mode(&self) -> bool

When true hand crafting is free and instant.

Source

pub fn crafting_queue(&self) -> Vec<CraftingQueueItem>

The current crafting queue items.

Source

pub fn crafting_queue_progress(&self) -> f64

The crafting queue progress in the range [0-1]. 0 when no recipe is being crafted.

Source

pub fn crafting_queue_size(&self) -> u32

Size of the crafting queue.

Source

pub fn cursor_ghost(&self) -> ItemIDAndQualityIDPair

The ghost prototype in the player’s cursor.

Items in the cursor stack will take priority over the cursor ghost.

Source

pub fn cursor_record(&self) -> LuaRecord

The blueprint record in the player’s cursor.

Source

pub fn cursor_stack(&self) -> LuaItemStack

The player’s cursor stack. nil if the player controller is a spectator.

Source

pub fn driving(&self) -> bool

true if the player is in a vehicle. Writing to this attribute puts the player in or out of a vehicle.

Source

pub fn drop_item_distance(&self) -> u32

The item drop distance of this character or max uint when not a character or player connected to a character.

Source

pub fn flight_height(&self) -> f64

The current flight height for this player or character entity.

When called on an entity, only valid if this entity is a character.

Source

pub fn following_robots(&self) -> Vec<LuaEntity>

The current combat robots following the character.

When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).

Source

pub fn force(&self) -> LuaForce

The force of this entity. Reading will always give a LuaForce, but it is possible to assign either string, uint8 or LuaForce to this attribute to change the force.

Source

pub fn force_index(&self) -> u32

Unique index (ID) associated with the force of this entity.

Source

pub fn hub(&self) -> LuaEntity

The space platform hub the player is currently sitting in.

Source

pub fn in_combat(&self) -> bool

Whether this character entity is in combat.

Source

pub fn is_flying(&self) -> bool

If this player or character entity is flying.

When called on an entity, only valid if this entity is a character.

Source

pub fn item_pickup_distance(&self) -> f64

The item pickup distance of this character or max double when not a character or player connected to a character.

Source

pub fn loot_pickup_distance(&self) -> f64

The loot pickup distance of this character or max double when not a character or player connected to a character.

Source

pub fn mining_progress(&self) -> f64

For characters and players the number is between 0 and 1.

For mining drills the number is with the range [0, mining_target.prototype.mineable_properties.mining_time].

For all other types the number is 0.

Source

pub fn mining_state(&self) -> LuaControlMiningState

Current mining state. Will error if written to with a controller_type other than character, god, or editor.

When the player isn’t mining tiles the player will mine whatever entity is currently selected. See LuaControl::selected and LuaControl::update_selected_entity.

Source

pub fn opened(&self) -> LuaAny

The GUI the player currently has open.

This is the GUI that will asked to close (by firing the on_gui_closed event) when the Esc or E keys are pressed. If this attribute is non-nil, then writing nil or a new GUI to it will ask the existing GUI to close.

Write supports any of the types. Read will return the entity, equipment, equipment-grid, player, element, inventory, item or nil.

Source

pub fn opened_gui_type(&self) -> &str

Source

pub fn picking_state(&self) -> bool

Current item-picking state.

Source

pub fn position(&self) -> MapPosition

The current position of the entity.

Source

pub fn reach_distance(&self) -> u32

The reach distance of this character or max uint when not a character or player connected to a character.

Source

pub fn render_position(&self) -> MapPosition

The current render position of the entity.

Source

pub fn repair_state(&self) -> LuaControlRepairState

Current repair state.

Source

pub fn resource_reach_distance(&self) -> f64

The resource reach distance of this character or max double when not a character or player connected to a character.

Source

pub fn riding_state(&self) -> RidingState

Current riding state of this car, or of the car this player is riding in.

Source

pub fn selected(&self) -> LuaEntity

The currently selected entity. Assigning an entity will select it if is selectable, otherwise the selection is cleared.

Source

pub fn shooting_state(&self) -> LuaControlShootingState

Current shooting state.

Source

pub fn surface(&self) -> LuaSurface

The surface this entity is currently on.

Source

pub fn surface_index(&self) -> u32

Unique index (ID) associated with the surface this entity is currently on.

Source

pub fn vehicle(&self) -> LuaEntity

The vehicle the player is currently sitting in.

Source

pub fn walking_state(&self) -> LuaControlWalkingState

Current walking state of the player, or the spider-vehicle the character is driving.

Source

pub fn absorbed_pollution(&self) -> f64

Source

pub fn active(&self) -> bool

A deactivated entity will stop all of 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 being marked for deconstruction.

If this entity is not considered updatable then this always returns false.

Source

pub fn ai_settings(&self) -> LuaAISettings

The AI settings of this unit.

Source

pub fn alert_parameters(&self) -> ProgrammableSpeakerAlertParameters

Source

pub fn allow_dispatching_robots(&self) -> bool

Whether this entity’s personal roboports are allowed to dispatch robots.

Source

pub fn always_on(&self) -> bool

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

Source

pub fn amount(&self) -> u32

Count of resource units contained.

Source

pub fn armed(&self) -> bool

Whether this land mine is armed.

Source

pub fn artillery_auto_targeting(&self) -> bool

If this artillery auto-targets enemies.

Source

pub fn associated_player(&self) -> LuaPlayer

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.

Source

pub fn attached_cargo_pod(&self) -> LuaEntity

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

Source

pub fn autopilot_destination(&self) -> MapPosition

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

Source

pub fn autopilot_destinations(&self) -> Vec<MapPosition>

The queued destination positions of spidertron’s autopilot.

Source

pub fn autopilot_patrol_size(&self) -> u32

When there are this many waypoints left the spider vehicle will start patrolling along them.

Setting this to 0 will disable patrolling.

Source

pub fn backer_name(&self) -> &str

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.

Source

pub fn base_damage_modifiers(&self) -> TriggerModifierData

Source

pub fn beacons_count(&self) -> u32

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

Source

pub fn belt_neighbours(&self) -> LuaEntityBeltNeighbours

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::underground_belt_neighbour for that.

Source

pub fn belt_shape(&self) -> LuaEntityBeltShape

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

Source

pub fn belt_to_ground_type(&self) -> BeltConnectionType

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

Source

pub fn bonus_damage_modifiers(&self) -> TriggerModifierData

Source

pub fn bonus_mining_progress(&self) -> f64

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.

Source

pub fn bonus_progress(&self) -> f64

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

Source

pub fn bounding_box(&self) -> BoundingBox

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

Source

pub fn burner(&self) -> LuaBurner

The burner energy source for this entity, if any.

Source

pub fn cargo_bay_connection_owner(&self) -> LuaEntity

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

Source

pub fn cargo_hatches(&self) -> Vec<LuaCargoHatch>

The cargo hatches owned by this entity if any.

Source

pub fn cargo_pod_destination(&self) -> CargoDestination

The destination of this cargo pod entity.

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

Source

pub fn cargo_pod_origin(&self) -> LuaEntity

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

Source

pub fn cargo_pod_state(&self) -> LuaEntityCargoPodState

The state of this cargo pod entity.

Source

pub fn chain_signal_state(&self) -> &str

The state of this chain signal.

Source

pub fn character_corpse_death_cause(&self) -> &str

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

Source

pub fn character_corpse_player_index(&self) -> u32

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.

Source

pub fn character_corpse_tick_of_death(&self) -> u32

The tick this character corpse died at.

Source

pub fn cliff_neighbours(&self) -> LuaEntityCliffNeighbours

Table of cliff neighbours.

Source

pub fn cliff_orientation(&self) -> CliffOrientation

The orientation of this cliff.

Source

pub fn color(&self) -> 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.

Source

pub fn combat_robot_owner(&self) -> LuaEntity

The owner of this combat robot, if any.

Source

pub fn combinator_description(&self) -> &str

The description on this combinator.

Source

pub fn commandable(&self) -> LuaCommandable

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

Source

pub fn connected_rail(&self) -> LuaEntity

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

Source

pub fn connected_rail_direction(&self) -> &str

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

Source

pub fn consumption_bonus(&self) -> f64

The consumption bonus of this entity.

Source

pub fn consumption_modifier(&self) -> f32

Multiplies the energy consumption.

Source

pub fn copy_color_from_train_stop(&self) -> bool

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

Source

pub fn corpse_expires(&self) -> bool

Whether this corpse will ever fade away.

Source

pub fn corpse_immune_to_entity_placement(&self) -> bool

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.

Source

pub fn crafting_progress(&self) -> f32

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

Source

pub fn crafting_speed(&self) -> f64

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

Source

pub fn crane_destination(&self) -> MapPosition

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

Source

pub fn crane_destination_3d(&self) -> Vector3D

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

Source

pub fn crane_end_position_3d(&self) -> Vector3D

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

Source

pub fn crane_grappler_destination(&self) -> LuaAny

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.

Source

pub fn crane_grappler_destination_3d(&self) -> LuaAny

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.

Source

pub fn created_by_corpse(&self) -> LuaEntity

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

Source

pub fn custom_status(&self) -> CustomEntityStatus

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

Source

pub fn damage_dealt(&self) -> f64

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

Source

pub fn destructible(&self) -> bool

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.

Source

pub fn direction(&self) -> &str

The current direction this entity is facing.

Source

pub fn disabled_by_control_behavior(&self) -> bool

If the updatable entity is disabled by control behavior.

Always returns false if this entity is not considered updatable.

Source

pub fn disabled_by_recipe(&self) -> bool

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.

Source

pub fn disabled_by_script(&self) -> bool

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.

Source

pub fn display_panel_always_show(&self) -> bool

Source

pub fn display_panel_icon(&self) -> SignalID

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

Source

pub fn display_panel_show_in_chart(&self) -> bool

Source

pub fn display_panel_text(&self) -> &str

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

Source

pub fn draw_data(&self) -> RollingStockDrawData

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

Source

pub fn driver_is_gunner(&self) -> bool

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.

Source

pub fn drop_position(&self) -> MapPosition

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.

Source

pub fn drop_target(&self) -> LuaEntity

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.

Source

pub fn effective_speed(&self) -> f32

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.

Source

pub fn effectivity_modifier(&self) -> f32

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

Source

pub fn effects(&self) -> ModuleEffects

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

Source

pub fn electric_buffer_size(&self) -> f64

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.

Source

pub fn electric_drain(&self) -> f64

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

Source

pub fn electric_emissions_per_joule(&self) -> HashMap<String, f64>

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.

Source

pub fn electric_interface_mode(&self) -> &str

Mode this ElectricEnergyInterface is in. Mode changes how the interface interacts with electric network: if its an electric producer, consumer and what priority it has.

Source

pub fn electric_network(&self) -> LuaElectricSubNetwork

Electric network this entity is connected to.

This can be used with electric poles, in which case the network will be the same as the one obtained from copper wire connector.

If this entity has an electric energy source, only a primary network will be provided. To also get other networks for entities in range of multiple networks, use LuaEntity::electric_networks instead.

Source

pub fn electric_network_id(&self) -> u32

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

Source

pub fn electric_network_statistics(&self) -> LuaFlowStatistics

The electric network statistics for this electric pole.

If this electric pole becomes invalid, the flow statistics obtained from it will also become invalid. If this electric pole becomes part of a different electric network, the flow statistics will be for the new electric network this pole is part of.

Source

pub fn electric_networks(&self) -> Vec<LuaElectricSubNetwork>

Electric networks this entity with an electric energy source is connected to.

No array is given if this entity has no electric energy source.

Empty array will be given if this entity is not in range of any networks.

Compared to LuaEntity::electric_network, this does not work with electric poles since they do not have an electric energy source and as such can only belong to one network at a time.

Source

pub fn enable_logistics_while_moving(&self) -> bool

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

Source

pub fn energy(&self) -> f64

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.

Source

pub fn energy_generated_last_tick(&self) -> f64

How much energy this generator generated in the last tick.

Source

pub fn entity_label(&self) -> &str

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

Source

pub fn filter_slot_count(&self) -> u32

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

Source

pub fn fluidbox_neighbours(&self) -> Vec<Vec<LuaEntity>>

A list of neighbours connected to fluidboxes of this entity. Neighbours are grouped by index of fluid box of this entity to which they are connected. For more detailed informations please use LuaEntity::get_fluid_box_neighbours.

Source

pub fn fluids_count(&self) -> u32

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.

Source

pub fn follow_offset(&self) -> Vector

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

Source

pub fn follow_target(&self) -> LuaEntity

The follow target of this spidertron, if any.

Source

pub fn friction_modifier(&self) -> f32

Multiplies the car friction rate.

Source

pub fn frozen(&self) -> bool

Whether the freezable entity is currently frozen.

Always returns false if this entity is not considered freezable.

Source

pub fn ghost_localised_description(&self) -> &str

Source

pub fn ghost_localised_name(&self) -> &str

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

Source

pub fn ghost_name(&self) -> &str

Name of the entity or tile contained in this ghost.

Source

pub fn ghost_prototype(&self) -> LuaAny

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

Source

pub fn ghost_type(&self) -> &str

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

Source

pub fn ghost_unit_number(&self) -> u64

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.

Source

pub fn gps_tag(&self) -> &str

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.

Source

pub fn graphics_variation(&self) -> u8

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

Source

pub fn grid(&self) -> LuaEquipmentGrid

This entity’s equipment grid, if any.

Source

pub fn health(&self) -> f32

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.

Source

pub fn heat_neighbours(&self) -> Vec<LuaEntity>

The entities connected to this entities heat buffer.

Source

pub fn held_stack(&self) -> LuaItemStack

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

Source

pub fn held_stack_position(&self) -> MapPosition

Current position of the inserter’s “hand”.

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

Source

pub fn highlight_box_type(&self) -> CursorBoxRenderType

The highlight box type of this highlight box entity.

Source

pub fn ignore_unprioritised_targets(&self) -> bool

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

Source

pub fn infinity_container_filters(&self) -> Vec<InfinityInventoryFilter>

The filters for this infinity container.

Source

pub fn initial_amount(&self) -> u32

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.

Source

pub fn input_flow_limit(&self) -> f64

Max amount of energy this ElectricEnergyInterface will take from electric network in one tick.

Source

pub fn insert_plan(&self) -> Vec<BlueprintInsertPlan>

The insert plan for this ghost or item request proxy.

Source

pub fn inserter_filter_mode(&self) -> LuaEntityInserterFilterMode

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

Source

pub fn inserter_spoil_priority(&self) -> SpoilPriority

The spoil priority for this inserter.

Source

pub fn inserter_stack_size_override(&self) -> u32

Sets the stack size limit on this inserter.

Set to 0 to reset.

Source

pub fn inserter_target_pickup_count(&self) -> u32

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.

Source

pub fn is_entity_with_health(&self) -> bool

If this entity is EntityWithHealth

Source

pub fn is_entity_with_owner(&self) -> bool

If this entity is EntityWithOwner

Source

pub fn is_freezable(&self) -> bool

Whether the entity is freezable and considered a FreezableEntity.

Source

pub fn is_headed_to_trains_front(&self) -> bool

If the rolling stock is facing train’s front.

Source

pub fn is_military_target(&self) -> bool

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

Source

pub fn is_updatable(&self) -> bool

Whether the entity is updatable and considered an UpdatableEntity.

Source

pub fn item_request_proxy(&self) -> LuaEntity

The first found item request proxy targeting this entity.

Source

pub fn item_requests(&self) -> Vec<ItemWithQualityCount>

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

Source

pub fn kills(&self) -> u32

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

Source

pub fn last_user(&self) -> LuaPlayer

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.

The link ID this linked container is using.

Source

pub fn linked_belt_neighbour(&self) -> LuaEntity

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

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

Source

pub fn linked_belt_type(&self) -> BeltConnectionType

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

Source

pub fn loader_belt_stack_size_override(&self) -> u8

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.

Source

pub fn loader_container(&self) -> LuaEntity

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

Source

pub fn loader_filter_mode(&self) -> PrototypeFilterMode

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

Source

pub fn loader_type(&self) -> BeltConnectionType

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

Source

pub fn localised_description(&self) -> &str

Source

pub fn localised_name(&self) -> &str

Localised name of the entity.

Source

pub fn logistic_cell(&self) -> LuaLogisticCell

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

Source

pub fn logistic_network(&self) -> LuaLogisticNetwork

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

Source

pub fn max_health(&self) -> f32

Max health of this entity.

Source

pub fn minable(&self) -> bool

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

Source

pub fn minable_flag(&self) -> bool

Script controlled flag that allows entity to be mined.

Source

pub fn mining_area(&self) -> BoundingBox

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

Source

pub fn mining_drill_filter_mode(&self) -> LuaEntityInserterFilterMode

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

Source

pub fn mining_target(&self) -> LuaEntity

The mining target, if any.

Source

pub fn mirroring(&self) -> bool

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.

Source

pub fn name(&self) -> &str

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

Source

pub fn name_tag(&self) -> &str

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.

Source

pub fn neighbour_bonus(&self) -> f64

The current total neighbour bonus of this reactor.

Source

pub fn neighbour_connectable_connections( &self, ) -> Vec<NeighbourConnectableConnection>

Connections of a neighbour connectable entity. Includes connections that aren’t currently connected to another entity.

Source

pub fn object_name(&self) -> &str

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.

Source

pub fn operable(&self) -> bool

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.

Source

pub fn orientation(&self) -> LuaAny

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

Source

pub fn output_flow_limit(&self) -> f64

Max amount of energy this ElectricEnergyInterface will provide to electric network in one tick.

Source

pub fn override_logistic_mode(&self) -> &str

The override logistic mode being used by this infinity container if it is overridden.

Source

pub fn owned_plants(&self) -> Vec<LuaEntity>

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

Source

pub fn parameters(&self) -> ProgrammableSpeakerParameters

Source

pub fn pickup_from_left_lane(&self) -> bool

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

Source

pub fn pickup_from_right_lane(&self) -> bool

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

Source

pub fn pickup_position(&self) -> MapPosition

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.

Source

pub fn pickup_target(&self) -> LuaEntity

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.

Source

pub fn player(&self) -> LuaPlayer

The player connected to this character, if any.

Source

pub fn pollution_bonus(&self) -> f64

The pollution bonus of this entity.

Source

pub fn power_production(&self) -> f64

The power production specific to the ElectricEnergyInterface entity type.

Source

pub fn power_switch_state(&self) -> bool

The state of this power switch.

Source

pub fn power_usage(&self) -> f64

The power usage specific to the ElectricEnergyInterface entity type.

Source

pub fn previous_recipe(&self) -> RecipeIDAndQualityIDPair

The previous recipe this furnace was using, if any.

Source

pub fn priority_targets(&self) -> Vec<LuaEntityPrototype>

The priority targets for this turret (if any).

Source

pub fn procession_tick(&self) -> u32

how far into the current procession the cargo pod is.

Source

pub fn productivity_bonus(&self) -> f64

The productivity bonus of this entity.

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

Source

pub fn products_finished(&self) -> u32

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

Source

pub fn protected(&self) -> bool

Automated weapons won’t target protected entities.

Source

pub fn prototype(&self) -> LuaEntityPrototype

The entity prototype of this entity.

Source

pub fn proxy_target(&self) -> LuaEntity

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

Source

pub fn proxy_target_entity(&self) -> LuaEntity

Entity of which inventory is exposed by this ProxyContainer

Source

pub fn proxy_target_inventory(&self) -> &str

Inventory index of the inventory that is exposed by this ProxyContainer

Source

pub fn pump_input_rail_targets(&self) -> Vec<LuaEntity>

The rail targets of this pump’s input

Source

pub fn pump_output_rail_targets(&self) -> Vec<LuaEntity>

The rail targets of this pump’s output

Source

pub fn pumped_last_tick(&self) -> f64

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

Source

pub fn quality(&self) -> LuaQualityPrototype

The quality of this entity.

Not all entities support quality and will give the “normal” quality back if they don’t.

Source

pub fn radar_scan_progress(&self) -> f32

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

Source

pub fn rail_layer(&self) -> &str

Gets rail layer of a given signal

Source

pub fn rail_length(&self) -> f64

Length of this rail piece.

Source

pub fn recipe_locked(&self) -> bool

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

Source

pub fn relative_turret_orientation(&self) -> LuaAny

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.

Source

pub fn removal_plan(&self) -> Vec<BlueprintInsertPlan>

The removal plan for this item request proxy.

Source

pub fn remove_unfiltered_items(&self) -> bool

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

Source

pub fn render_player(&self) -> LuaPlayer

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.

Source

pub fn render_to_forces(&self) -> Vec<LuaForce>

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.

Source

pub fn request_from_buffers(&self) -> bool

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

Useable only on entities that have requester slots.

Source

pub fn result_quality(&self) -> LuaQualityPrototype

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

Note: Writing nil is not allowed.

Source

pub fn robot_order_queue(&self) -> Vec<WorkerRobotOrder>

Get the current queue of robot orders.

Source

pub fn rocket(&self) -> LuaEntity

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

Source

pub fn rocket_parts(&self) -> u32

Number of rocket parts in this rocket silo.

Source

pub fn rocket_silo_status(&self) -> &str

The status of this rocket silo entity.

Source

pub fn rotatable(&self) -> bool

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.

Source

pub fn saved_request_filters(&self) -> SavedLogisticFilters

The saved logistic requests if they exist.

They exist when the infinity container was switched away from having the option to set logistic requests, for example by changing the logistic mode away from requester or buffer.

Source

pub fn saved_request_from_buffers(&self) -> bool

The saved request from buffers value if one exists.

The value exists when the infinity container was switched away from having the request from buffers option, for example by changing the logistic mode away from requester.

Source

pub fn saved_set_requests(&self) -> bool

The saved set requests value if one exists.

The value exists when the infinity container was switched away from having the set requests option, for example by changing the logistic mode away from requester or buffer.

Source

pub fn saved_storage_filters(&self) -> SavedLogisticFilters

The saved storage filters if they exist.

They exist when the infinity container was switched away from having the option to set storage filters, for example by changing the logistic mode away from storage.

Source

pub fn script_reservations_count(&self) -> u32

Amount of train stop reservations taken by script.

Source

pub fn secondary_bounding_box(&self) -> BoundingBox

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.

Source

pub fn secondary_selection_box(&self) -> BoundingBox

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.

Source

pub fn segmented_unit(&self) -> LuaSegmentedUnit

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

Source

pub fn selected_gun_index(&self) -> u32

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

Source

pub fn selection_box(&self) -> BoundingBox

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

Source

pub fn send_to_orbit_automatically(&self) -> bool

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

Source

pub fn shooting_target(&self) -> LuaEntity

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

Source

pub fn signal_state(&self) -> &str

The state of this rail signal.

Source

pub fn spawn_shift(&self) -> f64

Source

pub fn spawning_cooldown(&self) -> f64

Source

pub fn speed(&self) -> f32

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.

Source

pub fn speed_bonus(&self) -> f64

The speed bonus of this entity.

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

Source

pub fn splitter_filter(&self) -> ItemFilter

The filter for this splitter, if any is set.

Source

pub fn splitter_input_priority(&self) -> SplitterPriority

The input priority for this splitter.

Source

pub fn splitter_output_priority(&self) -> SplitterPriority

The output priority for this splitter.

Source

pub fn stack(&self) -> LuaItemStack

Source

pub fn status(&self) -> &str

The status of this entity, if any.

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

Source

pub fn sticked_to(&self) -> LuaEntity

The entity this sticker is sticked to.

Source

pub fn sticker_vehicle_modifiers(&self) -> LuaEntityStickerVehicleModifiers

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

Source

pub fn stickers(&self) -> Vec<LuaEntity>

The sticker entities attached to this entity, if any.

Source

pub fn storage_filter(&self) -> ItemIDAndQualityIDPair

The storage filter for this logistic storage container.

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

Source

pub fn supports_direction(&self) -> bool

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

Source

pub fn tags(&self) -> LuaAny

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

Source

pub fn temperature(&self) -> f64

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

Source

pub fn tick_grown(&self) -> u32

The tick when this plant is fully grown.

Source

pub fn tick_of_last_attack(&self) -> u32

The last tick this character entity was attacked.

Source

pub fn tick_of_last_damage(&self) -> u32

The last tick this character entity was damaged.

Source

pub fn tile_height(&self) -> u32

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.

Source

pub fn tile_width(&self) -> u32

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.

Source

pub fn time_to_live(&self) -> u64

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

Source

pub fn time_to_next_effect(&self) -> u32

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

Source

pub fn timeout(&self) -> u32

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

Source

pub fn to_be_looted(&self) -> bool

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

Source

pub fn torso_orientation(&self) -> LuaAny

The torso orientation of this spider vehicle.

Source

pub fn train(&self) -> LuaTrain

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

Source

pub fn train_reservations_count(&self) -> u32

Amount of train stop reservations taken by trains.

Source

pub fn train_stop_priority(&self) -> u8

Priority of this train stop.

Source

pub fn trains_count(&self) -> u32

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.

This value is equal to LuaEntity::train_reservations_count + LuaEntity::script_reservations_count.

Source

pub fn trains_in_block(&self) -> u32

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

Source

pub fn trains_limit(&self) -> u32

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.

Source

pub fn transitional_request_target(&self) -> LuaSpacePlatform

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

Source

pub fn tree_color_index(&self) -> u8

Index of the tree color.

Source

pub fn tree_color_index_max(&self) -> u8

Maximum index of the tree colors.

Source

pub fn tree_gray_stage_index(&self) -> u8

Index of the tree gray stage

Source

pub fn tree_gray_stage_index_max(&self) -> u8

Maximum index of the tree gray stages.

Source

pub fn tree_stage_index(&self) -> u8

Index of the tree stage.

Source

pub fn tree_stage_index_max(&self) -> u8

Maximum index of the tree stages.

Source

pub fn type(&self) -> &str

The entity prototype type of this entity.

Source

pub fn underground_belt_neighbour(&self) -> LuaEntity

Neighbour underground belt connected to this underground belt through underground lines.

Source

pub fn unit_number(&self) -> u64

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.

Source

pub fn units(&self) -> Vec<LuaEntity>

The units associated with this spawner entity.

Source

pub fn use_filters(&self) -> bool

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

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

Source

pub fn use_transitional_requests(&self) -> bool

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.

Source

pub fn valid(&self) -> bool

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.

Source

pub fn valve_threshold_override(&self) -> f32

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.

Source

pub fn vehicle_automatic_targeting_parameters( &self, ) -> VehicleAutomaticTargetingParameters

Read when this spidertron auto-targets enemies

Source

pub fn wall_neighbours(&self) -> LuaEntityWallNeighbours

Table of wall-connectable neighbours.

Source

pub fn begin_crafting(&self, params: LuaControlBeginCraftingParams) -> u32

Begins crafting the given count of the given recipe.

Source

pub fn can_insert(&self, items: LuaAny) -> bool

Can at least some items be inserted?

Source

pub fn can_place_entity(&self, params: LuaControlCanPlaceEntityParams) -> bool

Checks if this character or player can build the given entity at the given location on the surface the character or player is on.

Source

pub fn can_reach_entity(&self, entity: LuaEntity) -> bool

Can a given entity be opened or accessed?

Source

pub fn cancel_crafting(&self, params: LuaControlCancelCraftingParams)

Cancels the given amount of crafts at the given crafting queue position. If this causes any later crafts that depend on the cancelled one to have insufficient ingredients, those crafts will also be cancelled.

Source

pub fn clear_gui_arrow(&self)

Removes the arrow created by set_gui_arrow.

Source

pub fn clear_items_inside(&self)

Remove all items from this entity.

Source

pub fn clear_selected_entity(&self)

Unselect any selected entity.

Source

pub fn close_factoriopedia_gui(&self)

Closes the Factoriopedia GUI if it’s open.

Source

pub fn disable_flashlight(&self)

Disable the flashlight.

Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.

Source

pub fn enable_flashlight(&self)

Enable the flashlight.

Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.

Source

pub fn get_craftable_count(&self, recipe: LuaAny) -> u32

Gets the count of the given recipe that can be crafted.

Source

pub fn get_inventory(&self, inventory: &str) -> Option<LuaInventory>

Get an inventory belonging to this entity. This can be either the “main” inventory or some auxiliary one, like the module slots or logistic trash slots.

A given defines.inventory is only meaningful for the corresponding LuaObject type. EG: get_inventory(defines.inventory.character_main) is only meaningful if ‘this’ is a player character. You may get a value back but if the type of ‘this’ isn’t the type referred to by the defines.inventory it’s almost guaranteed to not be the inventory asked for.

Source

pub fn get_inventory_name(&self, inventory: &str) -> Option<&str>

Get name of inventory. Names match keys of defines.inventory.

Source

pub fn get_item_count(&self, item: Option<ItemFilter>) -> u32

Get the number of all or some items in this entity.

Source

pub fn get_main_inventory(&self) -> Option<LuaInventory>

Gets the main inventory for this character or player if this is a character or player.

Source

pub fn get_max_inventory_index(&self) -> &str

The highest index of all inventories this entity can use. Allows iteration over all of them if desired.

Source

pub fn get_requester_point(&self) -> Option<LuaLogisticPoint>

Gets the requester logistic point for this entity if it has one.

Source

pub fn has_items_inside(&self) -> bool

Does this entity have any item inside it?

Source

pub fn insert(&self, items: LuaAny) -> u32

Insert items into this entity. This works the same way as inserters or shift-clicking: the “best” inventory is chosen automatically.

Source

pub fn is_cursor_blueprint(&self) -> bool

Returns whether the player is holding a blueprint. This takes both blueprint items as well as blueprint records from the blueprint library into account.

Note that both this method refers to the currently selected blueprint, which means that a blueprint book with a selected blueprint will return the information as well.

Source

pub fn is_cursor_empty(&self) -> bool

Returns whether the player is holding something in the cursor. Takes into account items from the blueprint library, as well as items and ghost cursor.

Source

pub fn is_flashlight_enabled(&self) -> bool

Is the flashlight enabled for the current controller. Only supported by defines.controllers.character and defines.controllers.remote.

Source

pub fn is_player(&self) -> bool

When true control adapter is a LuaPlayer object, false for entities including characters with players.

Source

pub fn mine_entity(&self, entity: LuaEntity, force: Option<bool>) -> bool

Mines the given entity as if this player (or character) mined it.

Source

pub fn mine_tile(&self, tile: LuaTile) -> bool

Mines the given tile as if this player (or character) mined it.

Source

pub fn open_factoriopedia_gui(&self, prototype: Option<LuaAny>)

Open the Factoriopedia GUI and select a given entry, if any valid ID is given.

Source

pub fn open_technology_gui(&self, technology: Option<LuaAny>)

Open the technology GUI and select a given technology.

Source

pub fn remove_item(&self, items: LuaAny) -> u32

Remove items from this entity.

Source

pub fn set_driving(&self, driving: bool, force: Option<bool>)

Sets if this character or player is driving. Returns if the player or character is still driving.

Source

pub fn set_gui_arrow(&self, params: LuaControlSetGuiArrowParams)

Create an arrow which points at this entity. This is used in the tutorial. For examples, see control.lua in the campaign missions.

Source

pub fn teleport( &self, build_check_type: Option<&str>, position: MapPosition, raise_teleported: Option<bool>, snap_to_grid: Option<bool>, surface: Option<LuaAny>, ) -> bool

Teleport the entity to a given position, possibly on another surface.

Some entities may not be teleported. For instance, transport belts won’t allow teleportation and this method will always return false when used on any such entity.

You can also pass 1 or 2 numbers as the parameters and they will be used as relative teleport coordinates 'teleport(0, 1)' to move the entity 1 tile positive y. 'teleport(4)' to move the entity 4 tiles to the positive x.

script_raised_teleported will not be raised if teleporting a player with no character.

Source

pub fn update_selected_entity(&self, position: MapPosition)

Select an entity, as if by hovering the mouse above it.

Source

pub fn add_autopilot_destination( &self, attempt_patrol: Option<bool>, position: MapPosition, )

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

Source

pub fn add_fluid(&self, fluid: Fluid, index: LuaAny) -> LuaAny

Adds the given fluid to the entity’s given fluid storage if possible.

If the current fluid conflicts or the current filter conflicts the fluid may not be added.

Source

pub fn add_fluid_box_linked_connection( &self, other_entity: LuaEntity, other_linked_connection_id: u32, this_linked_connection_id: u32, )

Registers a linked fluidbox connection between this entity and other entity. Because entity may have multiple fluidboxes, each with multiple connections that could be linked, a unique value for this and other linked_connection_id may need to be given.

It may happen a linked fluidbox connection is not established immediately due to crafting machines being possible to not have certain fluidboxes exposed at a given point in time, but once they appear (due to recipe changes that would use them) they will be linked. Linked connections are persisted as (this_entity, this_linked_connection_id, other_entity, other_linked_connection_id) so if a pipe connection definition’s value of linked_connection_id changes existing connections may not restore correct connections.

Every fluidbox connection that was defined in prototypes as connection_type==“linked” may be linked to at most 1 other fluidbox. When trying to connect already used connection, previous connection will be removed.

Linked connections cannot go to the same entity even if they would be part of other fluidbox.

Source

pub fn add_fluid_segment_fluid(&self, fluid: Fluid, index: LuaAny) -> LuaAny

Adds the given fluid to the given storage’s fluid segment if possible.

Source

pub fn add_market_item(&self, offer: Offer)

Offer a thing on the market.

Source

pub fn apply_upgrade(&self) -> (Option<LuaEntity>, Option<LuaEntity>)

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

Source

pub fn can_be_destroyed(&self) -> bool

Whether the entity can be destroyed

Source

pub fn can_set_inventory_filter( &self, filter: ItemFilter, index: u32, inventory_index: &str, ) -> bool

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

Source

pub fn can_shoot(&self, position: MapPosition, target: LuaEntity) -> bool

Whether this character can shoot the given entity or position.

Source

pub fn can_wires_reach(&self, entity: LuaEntity) -> bool

Can wires reach between these entities.

Source

pub fn cancel_deconstruction(&self, force: LuaAny, player: Option<LuaAny>)

Cancels deconstruction if it is scheduled, does nothing otherwise.

Source

pub fn cancel_upgrade(&self, force: LuaAny, player: Option<LuaAny>) -> bool

Cancels upgrade if it is scheduled, does nothing otherwise.

Source

pub fn clear_fluid(&self, index: LuaAny) -> Option<Fluid>

Removes all fluid from the entity’s given fluid storage if possible.

Source

pub fn clear_fluid_inside(&self)

Remove all fluids from this entity and connected fluid segments.

Source

pub fn clear_fluid_segment_fluid(&self, index: LuaAny) -> Option<Fluid>

Clears the given fluid storage’s fluid segment.

Source

pub fn clear_fluids(&self) -> Vec<Fluid>

Clears all fluids in this entity but will not clear fluids in any fluid segments fluidboxes may be part of.

Source

pub fn clear_market_items(&self)

Removes all offers from a market.

Source

pub fn clear_stored_durability(&self)

Source

pub fn clear_tooltip_field(&self, id: u32)

Removes selected runtime tooltip field.

Source

pub fn clear_tooltip_fields(&self)

Removes all runtime tooltip fields attached to this entity.

Source

pub fn clone(&self, params: LuaEntityCloneParams) -> Option<LuaEntity>

Clones this entity.

Source

pub fn connect_linked_belts(&self, neighbour: Option<LuaEntity>)

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.

Source

pub fn connect_rolling_stock(&self, direction: &str) -> bool

Connects the rolling stock in the given direction.

Source

pub fn copy_settings( &self, by_player: Option<LuaAny>, entity: LuaEntity, ) -> Vec<ItemWithQualityCount>

Copies settings from the given entity onto this entity.

Source

pub fn create_build_effect_smoke(&self)

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}

Source

pub fn create_cargo_pod( &self, params: LuaEntityCreateCargoPodParams, ) -> Option<LuaEntity>

Creates a cargo pod if possible.

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

Source

pub fn damage( &self, cause: Option<LuaEntity>, damage: f32, force: LuaAny, source: Option<LuaEntity>, type: Option<LuaAny>, ) -> f32

Damages the entity.

Source

pub fn deplete(&self)

Depletes and destroys this resource entity.

Source

pub fn destroy(&self, params: LuaEntityDestroyParams) -> bool

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.

Source

pub fn die(&self, cause: Option<LuaEntity>, force: Option<LuaAny>) -> bool

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.

Source

pub fn disconnect_linked_belts(&self)

Disconnects linked belt from its neighbour.

Source

pub fn disconnect_rolling_stock(&self, direction: &str) -> bool

Tries to disconnect this rolling stock in the given direction.

Source

pub fn extract_fluid(&self, params: LuaEntityExtractFluidParams) -> LuaAny

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.

Source

pub fn flip(&self, params: LuaEntityFlipParams) -> bool

Flips this entity

Source

pub fn force_finish_ascending(&self)

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

Source

pub fn force_finish_descending(&self)

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

Source

pub fn get_beacon_effect_receivers(&self) -> Vec<LuaEntity>

Returns a table with all entities affected by this beacon

Source

pub fn get_beacons(&self) -> Option<Vec<LuaEntity>>

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)

Source

pub fn get_beam_source(&self) -> Option<BeamTarget>

Get the source of this beam.

Source

pub fn get_beam_target(&self) -> Option<BeamTarget>

Get the target of this beam.

Source

pub fn get_burnt_result_inventory(&self) -> Option<LuaInventory>

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

Source

pub fn get_cargo_bays(&self) -> Vec<LuaEntity>

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

Source

pub fn get_child_signals(&self) -> Vec<LuaEntity>

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.

Source

pub fn get_circuit_network( &self, wire_connector_id: &str, ) -> Option<LuaCircuitNetwork>

Source

pub fn get_connected_rail( &self, params: LuaEntityGetConnectedRailParams, ) -> (Option<LuaEntity>, Option<&str>, Option<&str>)

Source

pub fn get_connected_rails(&self) -> Vec<LuaEntity>

Get the rails that this signal is connected to.

Source

pub fn get_connected_rolling_stock( &self, direction: &str, ) -> (Option<LuaEntity>, Option<&str>)

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

Source

pub fn get_control_behavior(&self) -> Option<LuaControlBehavior>

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

Source

pub fn get_damage_to_be_taken(&self) -> Option<f32>

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

Source

pub fn get_driver(&self) -> Option<LuaAny>

Gets the driver of this vehicle if any.

Source

pub fn get_electric_input_flow_limit( &self, quality: Option<LuaAny>, ) -> Option<f64>

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

Source

pub fn get_electric_output_flow_limit( &self, quality: Option<LuaAny>, ) -> Option<f64>

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

Source

pub fn get_filter(&self, slot_index: u32) -> Option<LuaAny>

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

Source

pub fn get_fluid(&self, index: LuaAny) -> Option<Fluid>

Gets the fluid in the entity’s given fluid storage if one exists.

Source

pub fn get_fluid_box_linked_connection( &self, this_linked_connection_id: u32, ) -> (Option<LuaEntity>, Option<u32>)

Returns other end of a linked fluidbox connection.

Source

pub fn get_fluid_box_linked_connections(&self) -> Vec<FluidBoxConnectionRecord>

Returns list of all linked fluidbox connections registered for this entity.

Source

pub fn get_fluid_box_neighbours( &self, index: LuaAny, ) -> Option<Vec<FluidBoxNeighbourRecord>>

The entities the given fluidbox is connected to.

Source

pub fn get_fluid_box_pipe_connections( &self, index: LuaAny, ) -> Option<Vec<PipeConnection>>

Get the given connections and associated data of the fluidbox.

Source

pub fn get_fluid_box_prototype(&self, index: LuaAny) -> Option<LuaAny>

The prototype of the entity’s given fluid storage if one exists. If this is used on a fluidbox of a crafting machine which due to recipe was created by merging multiple prototypes, a table of prototypes that were merged will be returned instead For storages on entities that have fluid storage but no prototype for those storages (fluid wagons, and fluid turrets) this returns nil.

Source

pub fn get_fluid_capacity(&self, index: LuaAny) -> LuaAny

Gets the maximum capacity of the entity’s given fluid storage.

Source

pub fn get_fluid_contents(&self) -> HashMap<String, LuaAny>

Get amounts of all fluids in this entity.

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

Source

pub fn get_fluid_count(&self, fluid: Option<&str>) -> LuaAny

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

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

Source

pub fn get_fluid_filter(&self, index: LuaAny) -> Option<FluidFilter>

Get a fluidbox filter, such as the filter of a pump.

Source

pub fn get_fluid_segment_capacity(&self, index: LuaAny) -> LuaAny

Gets the maximum capacity of the given fluid storage’s segment.

Source

pub fn get_fluid_segment_extent_bounding_box( &self, index: LuaAny, ) -> BoundingBox

Gets the current extent bounding box of of the given fluid storage’s segment.

Source

pub fn get_fluid_segment_filter(&self, index: LuaAny) -> Option<FluidFilter>

Gets the filter of the given fluid storage’s segment. The filter is based on the filters set on the fluidboxes of the segment, so it can’t be set directly on the segment.

Source

pub fn get_fluid_segment_fluid(&self, index: LuaAny) -> Option<Fluid>

The fluid within the given storage’s fluid segment.

Source

pub fn get_fluid_segment_id(&self, index: LuaAny) -> u32

Source

pub fn get_fluid_source_fluid(&self) -> Option<&str>

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.

Source

pub fn get_fluid_source_tile(&self) -> TilePosition

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

Source

pub fn get_fuel_inventory(&self) -> Option<LuaInventory>

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

Source

pub fn get_health_ratio(&self) -> Option<f32>

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

Source

pub fn get_heat_setting(&self) -> HeatSetting

Gets the heat setting for this heat interface.

Source

pub fn get_inbound_signals(&self) -> Vec<LuaEntity>

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

Source

pub fn get_infinity_container_filter( &self, index: u32, ) -> Option<InfinityInventoryFilter>

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

Source

pub fn get_infinity_pipe_filter(&self) -> Option<InfinityPipeFilter>

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

Source

pub fn get_inventory_bar(&self, inventory_index: &str) -> u32

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

Source

pub fn get_inventory_filter( &self, index: u32, inventory_index: &str, ) -> Option<ItemFilter>

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

Source

pub fn get_inventory_size_override(&self, inventory_index: &str) -> Option<u16>

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

Source

pub fn get_item_insert_specification( &self, mirrored: Option<bool>, position: MapPosition, ) -> (u32, f32)

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.

Source

pub fn get_line_item_position(&self, index: &str, position: f32) -> MapPosition

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

Source

pub fn get_logistic_point(&self, index: Option<&str>) -> Option<LuaAny>

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

Source

pub fn get_logistic_sections(&self) -> Option<LuaLogisticSections>

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

Source

pub fn get_market_items(&self) -> Vec<Offer>

Get all offers in a market as an array.

Source

pub fn get_max_transport_line_index(&self) -> &str

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

Source

pub fn get_module_inventory(&self) -> Option<LuaInventory>

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

Source

pub fn get_movement(&self) -> Vector

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.

Source

pub fn get_or_create_control_behavior(&self) -> Option<LuaControlBehavior>

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

Source

pub fn get_outbound_signals(&self) -> Vec<LuaEntity>

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

Source

pub fn get_output_inventory(&self) -> Option<LuaInventory>

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

Source

pub fn get_parent_signals(&self) -> Vec<LuaEntity>

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.

Source

pub fn get_passenger(&self) -> Option<LuaAny>

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.

Source

pub fn get_priority_target(&self, index: u32) -> Option<LuaEntityPrototype>

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

Source

pub fn get_radius(&self) -> f64

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.

Source

pub fn get_rail_end(&self, direction: &str) -> LuaRailEnd

Gets a LuaRailEnd object for specified end of this rail

Source

pub fn get_rail_segment_end(&self, direction: &str) -> (LuaEntity, &str)

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.

Source

pub fn get_rail_segment_length(&self) -> f64

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.

Source

pub fn get_rail_segment_overlaps(&self) -> Vec<LuaEntity>

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.

Source

pub fn get_rail_segment_rails(&self, direction: &str) -> Vec<LuaEntity>

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.

Source

pub fn get_rail_segment_signal( &self, direction: &str, in_else_out: bool, ) -> Option<LuaEntity>

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.

Source

pub fn get_rail_segment_stop(&self, direction: &str) -> Option<LuaEntity>

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.

Source

pub fn get_recipe(&self) -> (Option<LuaRecipe>, Option<LuaQualityPrototype>)

Current recipe being assembled by this machine, if any.

Source

pub fn get_signal( &self, extra_wire_connector_id: Option<&str>, signal: SignalID, wire_connector_id: &str, ) -> i32

Read a single signal from the selected wire connector

Source

pub fn get_signals( &self, extra_wire_connector_id: Option<&str>, wire_connector_id: &str, ) -> Option<Vec<Signal>>

Read all signals from the selected wire connector.

Source

pub fn get_spider_legs(&self) -> Vec<LuaEntity>

Gets legs of given SpiderVehicle.

Source

pub fn get_stopped_train(&self) -> Option<LuaTrain>

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

Source

pub fn get_stored_durability(&self, item: LuaAny) -> LabStoredDurability

Source

pub fn get_tooltip_field(&self, id: u32) -> Option<RuntimeTooltipField>

Gets selected runtime tooltip field.

Source

pub fn get_tooltip_fields(&self) -> Vec<RuntimeTooltipField>

Gets all runtime tooltip fields attached to this entity.

Source

pub fn get_train_stop_trains(&self) -> Vec<LuaTrain>

The trains scheduled to stop at this train stop.

Source

pub fn get_transport_line(&self, index: &str) -> LuaTransportLine

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

Source

pub fn get_upgrade_target( &self, ) -> (Option<LuaEntityPrototype>, Option<LuaQualityPrototype>)

Returns the new entity prototype and its quality.

Source

pub fn get_wire_connector( &self, or_create: bool, wire_connector_id: &str, ) -> Option<LuaWireConnector>

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

Source

pub fn get_wire_connectors( &self, or_create: bool, ) -> HashMap<String, Box<LuaWireConnector>>

Gets all wire connectors of this entity

Source

pub fn ghost_has_flag(&self, flag: EntityPrototypeFlag) -> bool

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

Source

pub fn has_flag(&self, flag: EntityPrototypeFlag) -> bool

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

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

Source

pub fn has_fluid_segment(&self, index: LuaAny) -> bool

Whether the given fluid storage has a fluid segment.

Source

pub fn insert_fluid(&self, fluid: Fluid) -> LuaAny

Insert fluid into this entity. Fluidbox is chosen automatically.

Source

pub fn inventory_supports_bar(&self, inventory_index: &str) -> bool

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

Source

pub fn inventory_supports_filters(&self, inventory_index: &str) -> bool

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

Source

pub fn is_closed(&self) -> bool

Source

pub fn is_closing(&self) -> bool

Source

pub fn is_connected_to_electric_network(&self) -> bool

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.

Source

pub fn is_crafting(&self) -> bool

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.

Source

pub fn is_inventory_filtered(&self, inventory_index: &str) -> bool

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

Source

pub fn is_opened(&self) -> bool

Source

pub fn is_opening(&self) -> bool

Source

pub fn is_rail_in_same_rail_block_as(&self, other_rail: LuaEntity) -> bool

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

Source

pub fn is_rail_in_same_rail_segment_as(&self, other_rail: LuaEntity) -> bool

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

Source

pub fn is_registered_for_construction(&self) -> bool

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.

Source

pub fn is_registered_for_deconstruction(&self, force: LuaAny) -> bool

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.

Source

pub fn is_registered_for_repair(&self) -> bool

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.

Source

pub fn is_registered_for_upgrade(&self) -> bool

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.

Source

pub fn launch_rocket( &self, character: Option<LuaEntity>, destination: Option<CargoDestination>, ) -> bool

Source

pub fn mine(&self, params: LuaEntityMineParams) -> bool

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.

Source

pub fn order_deconstruction( &self, force: LuaAny, player: Option<LuaAny>, undo_index: Option<u32>, ) -> bool

Sets the entity to be deconstructed by construction robots.

Source

pub fn order_upgrade(&self, params: LuaEntityOrderUpgradeParams) -> bool

Sets the entity to be upgraded by construction robots.

Source

pub fn play_note( &self, instrument: u32, note: u32, stop_playing_sounds: Option<bool>, ) -> bool

Plays a note with the given instrument and note.

Source

pub fn register_tree(&self, tree: LuaEntity) -> bool

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.

Source

pub fn release_from_spawner(&self)

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

Source

pub fn remove_fluid(&self, amount: LuaAny, index: LuaAny) -> Option<Fluid>

Removes the given fluid amount from the entity’s given fluid storage if possible.

Source

pub fn remove_fluid_box_linked_connection(&self, this_linked_connection_id: u32)

Removes linked fluidbox connection record. If connected, other end will be also removed.

Source

pub fn remove_fluid_segment_fluid( &self, amount: LuaAny, index: LuaAny, ) -> Option<Fluid>

Removes the given fluid amount from the given storage’s fluid segment if possible.

Source

pub fn remove_market_item(&self, offer: u32) -> bool

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.

Source

pub fn request_to_close(&self, force: LuaAny)

Source

pub fn request_to_open(&self, extra_time: Option<u32>, force: LuaAny)

Source

pub fn revive( &self, params: LuaEntityReviveParams, ) -> (Option<Vec<ItemWithQualityCount>>, Option<LuaEntity>, Option<LuaEntity>)

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

Source

pub fn rotate(&self, params: LuaEntityRotateParams) -> bool

Rotates this entity as if the player rotated it.

Source

pub fn set_beam_source(&self, source: LuaAny)

Set the source of this beam.

Source

pub fn set_beam_target(&self, target: LuaAny)

Set the target of this beam.

Source

pub fn set_driver(&self, driver: LuaAny)

Sets the driver of this vehicle.

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

Source

pub fn set_filter(&self, filter: Option<LuaAny>, index: u32)

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.

Source

pub fn set_fluid(&self, fluid: Fluid, index: LuaAny) -> LuaAny

Sets the fluid in the entity’s given fluid storage to the provided fluid if possible.

Fluid filters may block setting the fluid, or less fluid may be set if it’s more than the maximum capacity.

Source

pub fn set_fluid_filter( &self, filter: Option<FluidFilter>, index: LuaAny, ) -> bool

Set a fluidbox filter, such as the filter of a pump.

Some entities cannot have their fluidbox filter set, notably fluid wagons and crafting machines.

Source

pub fn set_fluid_segment_fluid(&self, fluid: Fluid, index: LuaAny) -> LuaAny

Sets the fluid within the given storage’s fluid segment.

Source

pub fn set_heat_setting(&self, filter: HeatSetting)

Sets the heat setting for this heat interface.

Source

pub fn set_infinity_container_filter( &self, filter: Option<InfinityInventoryFilter>, index: u32, )

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

Source

pub fn set_infinity_pipe_filter(&self, filter: Option<InfinityPipeFilter>)

Sets the filter for this infinity pipe.

Source

pub fn set_inventory_bar(&self, bar: Option<u32>, inventory_index: &str)

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

Source

pub fn set_inventory_filter( &self, filter: Option<ItemFilter>, index: u32, inventory_index: &str, ) -> bool

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

Source

pub fn set_inventory_size_override( &self, inventory_index: &str, overflow: Option<LuaInventory>, size_override: Option<u16>, )

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.

Source

pub fn set_movement(&self, direction: Vector, speed: f64)

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.

Source

pub fn set_passenger(&self, passenger: LuaAny)

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.

Source

pub fn set_priority_target(&self, entity_id: Option<LuaAny>, index: u32)

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

Source

pub fn set_recipe( &self, quality: Option<LuaAny>, recipe: Option<LuaAny>, ) -> Vec<ItemWithQualityCount>

Sets the given recipe in this assembly machine.

Source

pub fn set_stored_durability( &self, durability: LabStoredDurability, item: LuaAny, )

Source

pub fn set_tooltip_field(&self, field: RuntimeTooltipField) -> u32

Adds or changes runtime tooltip field. If id is not given a new one will be allocated in a way that makes it unique within this entity. If a value is given that is already used, existing line will be updated.

Source

pub fn silent_revive( &self, params: LuaEntitySilentReviveParams, ) -> (Vec<ItemWithQualityCount>, Option<LuaEntity>, Option<LuaEntity>)

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

Source

pub fn spawn_decorations(&self)

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

Source

pub fn start_fading_out(&self)

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.

Source

pub fn stop_spider(&self)

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

Source

pub fn supports_backer_name(&self) -> bool

Whether this entity supports a backer name.

Source

pub fn to_be_deconstructed(&self) -> bool

Is this entity marked for deconstruction?

Source

pub fn to_be_upgraded(&self) -> bool

Is this entity marked for upgrade?

Source

pub fn toggle_equipment_movement_bonus(&self)

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.

Source

pub fn update_connections(&self)

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.

Trait Implementations§

Source§

impl Clone for LuaEntity

Source§

fn clone(&self) -> LuaEntity

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LuaEntity

Source§

impl Debug for LuaEntity

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LuaEntity

Source§

fn default() -> LuaEntity

Returns the “default value” for a type. Read more
Source§

impl Eq for LuaEntity

Source§

impl From<LuaEntity> for LuaAny

Source§

fn from(_: LuaEntity) -> Self

Converts to this type from the input type.
Source§

impl LuaObject for LuaEntity

Source§

impl PartialEq for LuaEntity

Source§

fn eq(&self, other: &LuaEntity) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LuaEntity

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.