pub struct LuaControl;Expand description
Implementations§
Source§impl LuaControl
impl LuaControl
Sourcepub fn build_distance(&self) -> u32
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.
Sourcepub fn cargo_pod(&self) -> LuaEntity
pub fn cargo_pod(&self) -> LuaEntity
The cargo pod the player is currently sitting in or the cargo pod attached to this rocket silo.
Sourcepub fn character_additional_mining_categories(&self) -> Vec<&str>
pub fn character_additional_mining_categories(&self) -> Vec<&str>
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_build_distance_bonus(&self) -> u32
pub fn character_build_distance_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_crafting_speed_modifier(&self) -> f64
pub fn character_crafting_speed_modifier(&self) -> f64
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_health_bonus(&self) -> f32
pub fn character_health_bonus(&self) -> f32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_inventory_slots_bonus(&self) -> u32
pub fn character_inventory_slots_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_item_drop_distance_bonus(&self) -> u32
pub fn character_item_drop_distance_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_item_pickup_distance_bonus(&self) -> u32
pub fn character_item_pickup_distance_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_loot_pickup_distance_bonus(&self) -> u32
pub fn character_loot_pickup_distance_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_maximum_following_robot_count_bonus(&self) -> u32
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).
Sourcepub fn character_mining_progress(&self) -> f64
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.
Sourcepub fn character_mining_speed_modifier(&self) -> f64
pub fn character_mining_speed_modifier(&self) -> f64
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_reach_distance_bonus(&self) -> u32
pub fn character_reach_distance_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_resource_reach_distance_bonus(&self) -> u32
pub fn character_resource_reach_distance_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn character_running_speed(&self) -> f64
pub fn character_running_speed(&self) -> f64
The current movement speed of this character, including effects from exoskeletons, tiles, stickers and shooting.
Sourcepub fn character_running_speed_modifier(&self) -> f64
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).
Sourcepub fn character_trash_slot_count_bonus(&self) -> u32
pub fn character_trash_slot_count_bonus(&self) -> u32
When called on a LuaPlayer, it must be associated with a character (see LuaPlayer::character).
Sourcepub fn cheat_mode(&self) -> bool
pub fn cheat_mode(&self) -> bool
When true hand crafting is free and instant.
Sourcepub fn crafting_queue(&self) -> Vec<CraftingQueueItem>
pub fn crafting_queue(&self) -> Vec<CraftingQueueItem>
The current crafting queue items.
Sourcepub fn crafting_queue_progress(&self) -> f64
pub fn crafting_queue_progress(&self) -> f64
The crafting queue progress in the range [0-1]. 0 when no recipe is being crafted.
Sourcepub fn crafting_queue_size(&self) -> u32
pub fn crafting_queue_size(&self) -> u32
Size of the crafting queue.
Sourcepub fn cursor_ghost(&self) -> ItemIDAndQualityIDPair
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.
Sourcepub fn cursor_record(&self) -> LuaRecord
pub fn cursor_record(&self) -> LuaRecord
The blueprint record in the player’s cursor.
Sourcepub fn cursor_stack(&self) -> LuaItemStack
pub fn cursor_stack(&self) -> LuaItemStack
The player’s cursor stack. nil if the player controller is a spectator.
Sourcepub fn driving(&self) -> bool
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.
Sourcepub fn drop_item_distance(&self) -> u32
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.
Sourcepub fn flight_height(&self) -> f64
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.
Sourcepub fn following_robots(&self) -> Vec<LuaEntity>
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).
Sourcepub fn force_index(&self) -> u32
pub fn force_index(&self) -> u32
Unique index (ID) associated with the force of this entity.
Sourcepub fn is_flying(&self) -> bool
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.
Sourcepub fn item_pickup_distance(&self) -> f64
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.
Sourcepub fn loot_pickup_distance(&self) -> f64
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.
Sourcepub fn mining_progress(&self) -> f64
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.
Sourcepub fn mining_state(&self) -> LuaControlMiningState
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.
Sourcepub fn opened(&self) -> LuaAny
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.
pub fn opened_gui_type(&self) -> &str
Sourcepub fn picking_state(&self) -> bool
pub fn picking_state(&self) -> bool
Current item-picking state.
Sourcepub fn position(&self) -> MapPosition
pub fn position(&self) -> MapPosition
The current position of the entity.
Sourcepub fn reach_distance(&self) -> u32
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.
Sourcepub fn render_position(&self) -> MapPosition
pub fn render_position(&self) -> MapPosition
The current render position of the entity.
Sourcepub fn repair_state(&self) -> LuaControlRepairState
pub fn repair_state(&self) -> LuaControlRepairState
Current repair state.
Sourcepub fn resource_reach_distance(&self) -> f64
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.
Sourcepub fn riding_state(&self) -> RidingState
pub fn riding_state(&self) -> RidingState
Current riding state of this car, or of the car this player is riding in.
Sourcepub fn selected(&self) -> LuaEntity
pub fn selected(&self) -> LuaEntity
The currently selected entity. Assigning an entity will select it if is selectable, otherwise the selection is cleared.
Sourcepub fn shooting_state(&self) -> LuaControlShootingState
pub fn shooting_state(&self) -> LuaControlShootingState
Current shooting state.
Sourcepub fn surface(&self) -> LuaSurface
pub fn surface(&self) -> LuaSurface
The surface this entity is currently on.
Sourcepub fn surface_index(&self) -> u32
pub fn surface_index(&self) -> u32
Unique index (ID) associated with the surface this entity is currently on.
Sourcepub fn walking_state(&self) -> LuaControlWalkingState
pub fn walking_state(&self) -> LuaControlWalkingState
Current walking state of the player, or the spider-vehicle the character is driving.
Sourcepub fn begin_crafting(&self, params: LuaControlBeginCraftingParams) -> u32
pub fn begin_crafting(&self, params: LuaControlBeginCraftingParams) -> u32
Begins crafting the given count of the given recipe.
Sourcepub fn can_insert(&self, items: LuaAny) -> bool
pub fn can_insert(&self, items: LuaAny) -> bool
Can at least some items be inserted?
Sourcepub fn can_place_entity(&self, params: LuaControlCanPlaceEntityParams) -> bool
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.
Sourcepub fn can_reach_entity(&self, entity: LuaEntity) -> bool
pub fn can_reach_entity(&self, entity: LuaEntity) -> bool
Can a given entity be opened or accessed?
Sourcepub fn cancel_crafting(&self, params: LuaControlCancelCraftingParams)
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.
Sourcepub fn clear_gui_arrow(&self)
pub fn clear_gui_arrow(&self)
Removes the arrow created by set_gui_arrow.
Sourcepub fn clear_items_inside(&self)
pub fn clear_items_inside(&self)
Remove all items from this entity.
Sourcepub fn clear_selected_entity(&self)
pub fn clear_selected_entity(&self)
Unselect any selected entity.
Sourcepub fn close_factoriopedia_gui(&self)
pub fn close_factoriopedia_gui(&self)
Closes the Factoriopedia GUI if it’s open.
Sourcepub fn disable_flashlight(&self)
pub fn disable_flashlight(&self)
Disable the flashlight.
Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.
Sourcepub fn enable_flashlight(&self)
pub fn enable_flashlight(&self)
Enable the flashlight.
Applied per controller. Only supported by defines.controllers.character and defines.controllers.remote.
Sourcepub fn get_craftable_count(&self, recipe: LuaAny) -> u32
pub fn get_craftable_count(&self, recipe: LuaAny) -> u32
Gets the count of the given recipe that can be crafted.
Sourcepub fn get_inventory(&self, inventory: &str) -> Option<LuaInventory>
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.
Sourcepub fn get_inventory_name(&self, inventory: &str) -> Option<&str>
pub fn get_inventory_name(&self, inventory: &str) -> Option<&str>
Get name of inventory. Names match keys of defines.inventory.
Sourcepub fn get_item_count(&self, item: Option<ItemFilter>) -> u32
pub fn get_item_count(&self, item: Option<ItemFilter>) -> u32
Get the number of all or some items in this entity.
Sourcepub fn get_main_inventory(&self) -> Option<LuaInventory>
pub fn get_main_inventory(&self) -> Option<LuaInventory>
Gets the main inventory for this character or player if this is a character or player.
Sourcepub fn get_max_inventory_index(&self) -> &str
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.
Sourcepub fn get_requester_point(&self) -> Option<LuaLogisticPoint>
pub fn get_requester_point(&self) -> Option<LuaLogisticPoint>
Gets the requester logistic point for this entity if it has one.
Sourcepub fn has_items_inside(&self) -> bool
pub fn has_items_inside(&self) -> bool
Does this entity have any item inside it?
Sourcepub fn insert(&self, items: LuaAny) -> u32
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.
Sourcepub fn is_cursor_blueprint(&self) -> bool
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.
Sourcepub fn is_cursor_empty(&self) -> bool
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.
Sourcepub fn is_flashlight_enabled(&self) -> bool
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.
Sourcepub fn is_player(&self) -> bool
pub fn is_player(&self) -> bool
When true control adapter is a LuaPlayer object, false for entities including characters with players.
Sourcepub fn mine_entity(&self, entity: LuaEntity, force: Option<bool>) -> bool
pub fn mine_entity(&self, entity: LuaEntity, force: Option<bool>) -> bool
Mines the given entity as if this player (or character) mined it.
Sourcepub fn mine_tile(&self, tile: LuaTile) -> bool
pub fn mine_tile(&self, tile: LuaTile) -> bool
Mines the given tile as if this player (or character) mined it.
Sourcepub fn open_factoriopedia_gui(&self, prototype: Option<LuaAny>)
pub fn open_factoriopedia_gui(&self, prototype: Option<LuaAny>)
Open the Factoriopedia GUI and select a given entry, if any valid ID is given.
Sourcepub fn open_technology_gui(&self, technology: Option<LuaAny>)
pub fn open_technology_gui(&self, technology: Option<LuaAny>)
Open the technology GUI and select a given technology.
Sourcepub fn remove_item(&self, items: LuaAny) -> u32
pub fn remove_item(&self, items: LuaAny) -> u32
Remove items from this entity.
Sourcepub fn set_driving(&self, driving: bool, force: Option<bool>)
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.
Sourcepub fn set_gui_arrow(&self, params: LuaControlSetGuiArrowParams)
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.
Sourcepub fn teleport(
&self,
build_check_type: Option<&str>,
position: MapPosition,
raise_teleported: Option<bool>,
snap_to_grid: Option<bool>,
surface: Option<LuaAny>,
) -> bool
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.
Sourcepub fn update_selected_entity(&self, position: MapPosition)
pub fn update_selected_entity(&self, position: MapPosition)
Select an entity, as if by hovering the mouse above it.
Trait Implementations§
Source§impl Clone for LuaControl
impl Clone for LuaControl
Source§fn clone(&self) -> LuaControl
fn clone(&self) -> LuaControl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more