Skip to main content

LuaControl

Struct LuaControl 

Source
pub struct LuaControl;
Expand description

This is an abstract base class containing the common functionality between LuaPlayer and entities (see LuaEntity). When accessing player-related functions through a LuaEntity, it must refer to a character entity.

Implementations§

Source§

impl LuaControl

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

Trait Implementations§

Source§

impl Clone for LuaControl

Source§

fn clone(&self) -> LuaControl

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 LuaControl

Source§

impl Debug for LuaControl

Source§

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

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

impl Default for LuaControl

Source§

fn default() -> LuaControl

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

impl Eq for LuaControl

Source§

impl From<LuaControl> for LuaAny

Source§

fn from(_: LuaControl) -> Self

Converts to this type from the input type.
Source§

impl LuaObject for LuaControl

Source§

impl PartialEq for LuaControl

Source§

fn eq(&self, other: &LuaControl) -> 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 LuaControl

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.