pub struct LuaPlayer;Expand description
A player in the game. Pay attention that a player may or may not have a character, which is the LuaEntity of the little guy running around the world doing things.
Implementations§
Source§impl LuaPlayer
impl LuaPlayer
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 admin(&self) -> bool
pub fn admin(&self) -> bool
true if the player is an admin.
Trying to change player admin status from the console when you aren’t an admin does nothing.
Sourcepub fn auto_sort_main_inventory(&self) -> bool
pub fn auto_sort_main_inventory(&self) -> bool
If the main inventory will be auto sorted.
Sourcepub fn blueprint_to_setup(&self) -> LuaItemStack
pub fn blueprint_to_setup(&self) -> LuaItemStack
The item stack containing a blueprint to be setup.
Sourcepub fn blueprints(&self) -> Vec<LuaRecord>
pub fn blueprints(&self) -> Vec<LuaRecord>
Records contained in the player’s blueprint library.
Sourcepub fn centered_on(&self) -> LuaEntity
pub fn centered_on(&self) -> LuaEntity
The entity being centered on in remote view.
When writing, the player will be switched to remote view (if not already in it) and centered on the given entity.
Sourcepub fn character(&self) -> LuaEntity
pub fn character(&self) -> LuaEntity
The character attached to this player, if any. Returns nil when the player is disconnected (see LuaPlayer::connected).
Sourcepub fn chat_color(&self) -> Color
pub fn chat_color(&self) -> Color
The color used when this player talks in game.
Sourcepub fn color(&self) -> Color
pub fn color(&self) -> Color
The color associated with the player. This will be used to tint the player’s character as well as their buildings and vehicles.
pub fn controller_type(&self) -> &str
Sourcepub fn current_music(&self) -> &str
pub fn current_music(&self) -> &str
The name of an ambient sound (music) the player is currently listening to.
If music is not playing, returns an empty string.
If the player is disconnected, returns the last played ambient sound.
Sourcepub fn cursor_stack_temporary(&self) -> bool
pub fn cursor_stack_temporary(&self) -> bool
Returns true if the current item stack in cursor will be destroyed after clearing the cursor. Manually putting it into inventory still preserves the item. If the cursor stack is not one of the supported types (blueprint, blueprint-book, deconstruction-planner, upgrade-planner), write operation will be silently ignored.
Sourcepub fn cutscene_character(&self) -> LuaEntity
pub fn cutscene_character(&self) -> LuaEntity
When in a cutscene; the character this player would be using once the cutscene is over, if any. Returns nil when the player is disconnected (see LuaPlayer::connected).
Sourcepub fn disable_space_map(&self) -> bool
pub fn disable_space_map(&self) -> bool
Set to true to disallow opening the space map and hide the space map button.
Sourcepub fn display_density_scale(&self) -> f64
pub fn display_density_scale(&self) -> f64
The display density scale for this player. The display density scale is the factor of LuaPlayer::display_scale that is determined by the physical DPI of the screen that Factorio is running on. In most cases, the default value is 1. If the player is playing on a high-density display, this value may be 2 or greater.
During on_player_created, this attribute will always return a scale of 1. To get the actual scale, listen to the on_player_display_density_scale_changed event raised shortly afterwards.
Sourcepub fn display_resolution(&self) -> DisplayResolution
pub fn display_resolution(&self) -> DisplayResolution
The display resolution for this player.
During on_player_created, this attribute will always return a resolution of {width=1920, height=1080}. To get the actual resolution, listen to the on_player_display_resolution_changed event raised shortly afterwards.
Sourcepub fn display_scale(&self) -> f64
pub fn display_scale(&self) -> f64
The display scale for this player.
During on_player_created, this attribute will always return a scale of 1. To get the actual scale, listen to the on_player_display_scale_changed event raised shortly afterwards.
Sourcepub fn drag_target(&self) -> DragTarget
pub fn drag_target(&self) -> DragTarget
The wire drag target for this player, if any.
Sourcepub fn entity_copy_source(&self) -> LuaEntity
pub fn entity_copy_source(&self) -> LuaEntity
The source entity used during entity settings copy-paste, if any.
Sourcepub fn game_view_settings(&self) -> LuaAny
pub fn game_view_settings(&self) -> LuaAny
The player’s game view settings.
pub fn gui(&self) -> LuaGui
Sourcepub fn hand_location(&self) -> ItemStackLocation
pub fn hand_location(&self) -> ItemStackLocation
The original location of the item in the cursor, marked with a hand. nil if the cursor stack is empty. When writing, the specified inventory slot must be empty and the cursor stack must not be empty.
Sourcepub fn hide_locked_prototypes_in_factoriopedia(&self) -> bool
pub fn hide_locked_prototypes_in_factoriopedia(&self) -> bool
Set to true to hide prototypes in Factoriopedia if they aren’t unlocked yet.
Sourcepub fn index(&self) -> u32
pub fn index(&self) -> u32
This player’s index in LuaGameScript::players (unique ID). It is assigned when a player is created, and remains so (even when the player is not connected) until the player is irreversibly removed. Indexes of removed players can be reused.
Sourcepub fn infinity_inventory_filters(&self) -> Vec<InfinityInventoryFilter>
pub fn infinity_inventory_filters(&self) -> Vec<InfinityInventoryFilter>
The filters for this map editor infinity inventory settings.
Sourcepub fn input_method(&self) -> &str
pub fn input_method(&self) -> &str
The input method of the player, mouse and keyboard or game controller
Sourcepub fn last_online(&self) -> u32
pub fn last_online(&self) -> u32
At what tick this player was last online.
Sourcepub fn locale(&self) -> &str
pub fn locale(&self) -> &str
The active locale for this player.
During on_player_created, this attribute will be en. To get the actual value, listen to the on_player_locale_changed event raised shortly afterwards.
Sourcepub fn map_view_settings(&self) -> LuaAny
pub fn map_view_settings(&self) -> LuaAny
The player’s map view settings. To write to this, use a table containing the fields that should be changed.
Sourcepub fn minimap_enabled(&self) -> bool
pub fn minimap_enabled(&self) -> bool
true if the minimap is visible.
Sourcepub fn mod_settings(&self) -> HashMap<String, ModSetting>
pub fn mod_settings(&self) -> HashMap<String, ModSetting>
The current per-player settings for the this player, indexed by prototype name. Returns the same structure as LuaSettings::get_player_settings. This table becomes invalid if its associated player does.
Even though this attribute is marked as read-only, individual settings can be changed by overwriting their ModSetting table. Mods can only change their own settings. Using the in-game console, all player settings can be changed.
Sourcepub fn object_name(&self) -> &str
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.
Sourcepub fn online_time(&self) -> u32
pub fn online_time(&self) -> u32
How many ticks did this player spend playing this save (all sessions combined).
Sourcepub fn opened_self(&self) -> bool
pub fn opened_self(&self) -> bool
true if the player opened itself. I.e. if they opened the character or god-controller GUI.
Sourcepub fn permission_group(&self) -> LuaPermissionGroup
pub fn permission_group(&self) -> LuaPermissionGroup
The permission group this player is part of, if any.
Sourcepub fn physical_controller_type(&self) -> &str
pub fn physical_controller_type(&self) -> &str
The player’s “physical” controller. When a player is in the remote controller, this specifies the controller they will return to. When the player is not in the remote controller, this is equivalent to LuaPlayer::controller_type.
Sourcepub fn physical_position(&self) -> MapPosition
pub fn physical_position(&self) -> MapPosition
The current position of this player’s physical controller.
Sourcepub fn physical_surface(&self) -> LuaSurface
pub fn physical_surface(&self) -> LuaSurface
The surface this player’s physical controller is on.
Sourcepub fn physical_surface_index(&self) -> u32
pub fn physical_surface_index(&self) -> u32
Unique ID associated with the surface this player’s physical controller is currently on.
Sourcepub fn physical_vehicle(&self) -> LuaEntity
pub fn physical_vehicle(&self) -> LuaEntity
The current vehicle of this player’s physical controller.
Sourcepub fn quick_bar_width(&self) -> u8
pub fn quick_bar_width(&self) -> u8
Amount of slots one row(page) of quickbar has.
Sourcepub fn remove_unfiltered_items(&self) -> bool
pub fn remove_unfiltered_items(&self) -> bool
If items not included in this map editor infinity inventory filters should be removed.
Sourcepub fn render_mode(&self) -> &str
pub fn render_mode(&self) -> &str
The render mode of the player, like map or zoom to world.
Sourcepub fn respawn_quality(&self) -> LuaQualityPrototype
pub fn respawn_quality(&self) -> LuaQualityPrototype
The quality used when this player respawns.
This can be set at any time however it is best to set it during the defines.events.on_player_died event.
Sourcepub fn saved_logistic_filters(&self) -> SavedLogisticFilters
pub fn saved_logistic_filters(&self) -> SavedLogisticFilters
The filters that will be applied when this player respawns. These only have meaning if the player is actively waiting to respawn.
Sourcepub fn show_on_map(&self) -> bool
pub fn show_on_map(&self) -> bool
If true, circle and name of given player is rendered on the map/chart.
Sourcepub fn spectator(&self) -> bool
pub fn spectator(&self) -> bool
If true, zoom-to-world noise effect will be disabled and environmental sounds will be based on zoom-to-world view instead of position of player’s character.
Sourcepub fn spidertron_remote_selection(&self) -> Vec<LuaEntity>
pub fn spidertron_remote_selection(&self) -> Vec<LuaEntity>
All SpiderVehicles currently selected by the player, if they are holding a spidertron remote.
Sourcepub fn stashed_controller_type(&self) -> &str
pub fn stashed_controller_type(&self) -> &str
The stashed controller type, if any. This is mainly useful when a player is in the map editor.
Sourcepub fn tag(&self) -> &str
pub fn tag(&self) -> &str
The tag that is shown after the player in chat, on the map and above multiplayer selection rectangles.
Sourcepub fn ticks_to_respawn(&self) -> u32
pub fn ticks_to_respawn(&self) -> u32
The number of ticks until this player will respawn. nil if this player is not waiting to respawn.
Set to nil to immediately respawn the player.
Set to any positive value to trigger the respawn state for this player.
Sourcepub fn undo_redo_stack(&self) -> LuaUndoRedoStack
pub fn undo_redo_stack(&self) -> LuaUndoRedoStack
The undo and redo stack for this player.
Sourcepub fn valid(&self) -> bool
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.
Sourcepub fn zoom(&self) -> f64
pub fn zoom(&self) -> f64
The current player controller’s zoom level. Must be positive. The baseline zoom level is 1. Values greater than 1 will zoom in closer to the world and values between 0 and 1 will zoom out away from the world.
Writing values outside the current zoom limits is always valid, but read values will always be clamped to the range defined by LuaPlayer::zoom_limits.
Sourcepub fn zoom_limits(&self) -> ZoomLimits
pub fn zoom_limits(&self) -> ZoomLimits
The player’s current controller’s zoom limits.
Reading this field creates a copy, so modifying the returned table’s fields directly will not alter the player’s zoom limits. To change the zoom limits for the player’s current controller, set the entire field to the desired ZoomLimits table.
Zoom limits are defined and remembered per controller type. If you set the zoom limits of the character controller, then every time the player uses the character controller, it will remember and use the zoom limits previously set. However, other controller types will not use the character controller zoom limits; each controller type must have its zoom limits defined separately.
To set the zoom limits of ANY controller type, not just the currently active one, use LuaPlayer::set_zoom_limits.
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.
Sourcepub fn activate_paste(&self)
pub fn activate_paste(&self)
Gets a copy of the currently selected blueprint in the clipboard queue into the player’s cursor, as if the player activated Paste.
Sourcepub fn add_alert(&self, entity: LuaEntity, type: &str)
pub fn add_alert(&self, entity: LuaEntity, type: &str)
Adds an alert to this player for the given entity of the given alert type.
Sourcepub fn add_custom_alert(
&self,
entity: LuaEntity,
icon: SignalID,
message: &str,
show_on_map: bool,
)
pub fn add_custom_alert( &self, entity: LuaEntity, icon: SignalID, message: &str, show_on_map: bool, )
Adds a custom alert to this player.
Sourcepub fn add_pin(&self, params: LuaPlayerAddPinParams)
pub fn add_pin(&self, params: LuaPlayerAddPinParams)
Adds a pin to this player for the given pin specification. Either entity, player, or surface and position must be defined.
Sourcepub fn add_recipe_notification(&self, recipe: LuaAny)
pub fn add_recipe_notification(&self, recipe: LuaAny)
Adds the given recipe to the list of recipe notifications for this player.
Sourcepub fn add_to_clipboard(&self, blueprint: LuaItemStack)
pub fn add_to_clipboard(&self, blueprint: LuaItemStack)
Adds the given blueprint to this player’s clipboard queue.
Sourcepub fn associate_character(&self, character: LuaEntity)
pub fn associate_character(&self, character: LuaEntity)
Associates a character with this player.
The character must not be connected to any controller.
If this player is currently disconnected (see LuaPlayer::connected) the character will be immediately “logged off”.
See LuaPlayer::get_associated_characters for more information.
Sourcepub fn build_from_cursor(&self, params: LuaPlayerBuildFromCursorParams)
pub fn build_from_cursor(&self, params: LuaPlayerBuildFromCursorParams)
Builds whatever is in the cursor on the surface the player is on. The cursor stack will automatically be reduced as if the player built normally.
Sourcepub fn can_build_from_cursor(
&self,
params: LuaPlayerCanBuildFromCursorParams,
) -> bool
pub fn can_build_from_cursor( &self, params: LuaPlayerCanBuildFromCursorParams, ) -> bool
Checks if this player can build what ever is in the cursor on the surface the player is on.
Sourcepub fn clear_console(&self)
pub fn clear_console(&self)
Clear the chat console.
Sourcepub fn clear_cursor(&self) -> bool
pub fn clear_cursor(&self) -> bool
Invokes the “clear cursor” action on the player as if the user pressed it.
Sourcepub fn clear_inventory_highlights(&self)
pub fn clear_inventory_highlights(&self)
Clears the blinking of the inventory based on insertion of items
Sourcepub fn clear_local_flying_texts(&self)
pub fn clear_local_flying_texts(&self)
Clear any active flying texts for this player.
Sourcepub fn clear_recipe_notification(&self, recipe: LuaAny)
pub fn clear_recipe_notification(&self, recipe: LuaAny)
Clears the given recipe from the list of recipe notifications for this player.
Sourcepub fn clear_recipe_notifications(&self)
pub fn clear_recipe_notifications(&self)
Clears all recipe notifications for this player.
Sourcepub fn clear_selection(&self)
pub fn clear_selection(&self)
Clears the player’s selection tool selection position.
Sourcepub fn connect_to_server(&self, params: LuaPlayerConnectToServerParams)
pub fn connect_to_server(&self, params: LuaPlayerConnectToServerParams)
Asks the player if they would like to connect to the given server.
If the “auto-accept-connect-to-server” interface setting is enabled, the prompt is skipped.
This only does anything when used on a multiplayer peer. Single player and server hosts will ignore the prompt.
Sourcepub fn create_character(&self, character: Option<LuaAny>) -> bool
pub fn create_character(&self, character: Option<LuaAny>) -> bool
Creates and attaches a character entity to this player.
The player must not have a character already connected and must be online (see LuaPlayer::connected).
Sourcepub fn create_local_flying_text(
&self,
params: LuaPlayerCreateLocalFlyingTextParams,
)
pub fn create_local_flying_text( &self, params: LuaPlayerCreateLocalFlyingTextParams, )
Spawn flying text that is only visible to this player. Either position or create_at_cursor are required. When create_at_cursor is true, all parameters other than text are ignored.
If no custom speed is set and the text is longer than 25 characters, its time_to_live and speed are dynamically adjusted to give the player more time to read it.
Local flying text is not saved, which means it will disappear after a save/load-cycle.
Sourcepub fn cursor_split(&self, index: u32, inventory: LuaInventory) -> bool
pub fn cursor_split(&self, index: u32, inventory: LuaInventory) -> bool
Performs the cursor split action on the given inventory at the given index as if the player did it.
Sourcepub fn cursor_transfer(&self, index: u32, inventory: LuaInventory) -> bool
pub fn cursor_transfer(&self, index: u32, inventory: LuaInventory) -> bool
Performs the cursor transfer action on the given inventory at the given index as if the player did it.
Sourcepub fn disable_alert(&self, alert_type: &str) -> bool
pub fn disable_alert(&self, alert_type: &str) -> bool
Disables alerts for the given alert category.
Sourcepub fn disable_recipe_groups(&self)
pub fn disable_recipe_groups(&self)
Disable recipe groups.
Sourcepub fn disable_recipe_subgroups(&self)
pub fn disable_recipe_subgroups(&self)
Disable recipe subgroups.
Sourcepub fn disassociate_character(&self, character: LuaEntity)
pub fn disassociate_character(&self, character: LuaEntity)
Disassociates a character from this player. This is functionally the same as setting LuaEntity::associated_player to nil.
See LuaPlayer::get_associated_characters for more information.
Sourcepub fn drag_wire(&self, params: LuaPlayerDragWireParams) -> bool
pub fn drag_wire(&self, params: LuaPlayerDragWireParams) -> bool
Start/end wire dragging at the specified location, wire type is based on the cursor contents
Sourcepub fn enable_alert(&self, alert_type: &str) -> bool
pub fn enable_alert(&self, alert_type: &str) -> bool
Enables alerts for the given alert category.
Sourcepub fn enable_recipe_groups(&self)
pub fn enable_recipe_groups(&self)
Enable recipe groups.
Sourcepub fn enable_recipe_subgroups(&self)
pub fn enable_recipe_subgroups(&self)
Enable recipe subgroups.
Sourcepub fn enter_space_platform(&self, space_platform: LuaSpacePlatform) -> bool
pub fn enter_space_platform(&self, space_platform: LuaSpacePlatform) -> bool
Enters the given space platform if possible.
Sourcepub fn exit_cutscene(&self)
pub fn exit_cutscene(&self)
Exit the current cutscene. Errors if not in a cutscene.
Sourcepub fn exit_remote_view(&self)
pub fn exit_remote_view(&self)
Exit remote view if possible. Exiting will fail if the player is in a rocket or in a platform.
Sourcepub fn get_active_quick_bar_page(&self, index: u32) -> Option<u8>
pub fn get_active_quick_bar_page(&self, index: u32) -> Option<u8>
Gets which quick bar page is being used for the given screen page or nil if not known.
Sourcepub fn get_alerts(&self, filter: AlertFilter) -> LuaAny
pub fn get_alerts(&self, filter: AlertFilter) -> LuaAny
Get all alerts matching the given filters, or all alerts if no filters are given.
Sourcepub fn get_associated_characters(&self) -> Vec<LuaEntity>
pub fn get_associated_characters(&self) -> Vec<LuaEntity>
The characters associated with this player.
The array will always be empty when the player is disconnected (see LuaPlayer::connected) regardless of there being associated characters.
Characters associated with this player will be logged off when this player disconnects but are not controlled by any player.
Sourcepub fn get_goal_description(&self) -> &str
pub fn get_goal_description(&self) -> &str
Get the current goal description, as a localised string.
Sourcepub fn get_infinity_inventory_filter(
&self,
index: u32,
) -> Option<InfinityInventoryFilter>
pub fn get_infinity_inventory_filter( &self, index: u32, ) -> Option<InfinityInventoryFilter>
Gets the filter for this map editor infinity filters at the given index or nil if the filter index doesn’t exist or is empty.
Sourcepub fn get_quick_bar_slot(
&self,
page_index: u8,
slot_index: u8,
) -> Option<QuickBarSlot>
pub fn get_quick_bar_slot( &self, page_index: u8, slot_index: u8, ) -> Option<QuickBarSlot>
Gets the quick bar filter for the given slot or nil.
Sourcepub fn get_recipe_notifications(&self) -> Vec<LuaRecipePrototype>
pub fn get_recipe_notifications(&self) -> Vec<LuaRecipePrototype>
Get all recipes that currently have recipe notifications for this player.
Sourcepub fn is_alert_enabled(&self, alert_type: &str) -> bool
pub fn is_alert_enabled(&self, alert_type: &str) -> bool
If the given alert type is currently enabled.
Sourcepub fn is_alert_muted(&self, alert_type: &str) -> bool
pub fn is_alert_muted(&self, alert_type: &str) -> bool
If the given alert type is currently muted.
Sourcepub fn is_shortcut_available(&self, prototype_name: &str) -> bool
pub fn is_shortcut_available(&self, prototype_name: &str) -> bool
Is a custom Lua shortcut currently available?
Sourcepub fn is_shortcut_toggled(&self, prototype_name: &str) -> bool
pub fn is_shortcut_toggled(&self, prototype_name: &str) -> bool
Is a custom Lua shortcut currently toggled?
Sourcepub fn jump_to_cutscene_waypoint(&self, waypoint_index: u32)
pub fn jump_to_cutscene_waypoint(&self, waypoint_index: u32)
Jump to the specified cutscene waypoint. Only works when the player is viewing a cutscene.
Sourcepub fn land_on_planet(&self) -> bool
pub fn land_on_planet(&self) -> bool
Ejects this player from the current space platform and lands on the current planet.
Sourcepub fn leave_space_platform(&self)
pub fn leave_space_platform(&self)
Ejects this player from the current space platform if in a platform. The player is left on the platform at the position of the hub.
Sourcepub fn mute_alert(&self, alert_type: &str) -> bool
pub fn mute_alert(&self, alert_type: &str) -> bool
Mutes alerts for the given alert category.
Sourcepub fn pipette(
&self,
allow_ghost: Option<bool>,
id: LuaAny,
quality: Option<LuaAny>,
) -> bool
pub fn pipette( &self, allow_ghost: Option<bool>, id: LuaAny, quality: Option<LuaAny>, ) -> bool
Emulates the player using the “smart pipette” that results in the given id and quality.
Sourcepub fn play_music(&self, music_specification: PlayMusicSpecification)
pub fn play_music(&self, music_specification: PlayMusicSpecification)
Play a music track for this player.
Sourcepub fn play_sound(&self, sound_specification: PlaySoundSpecification)
pub fn play_sound(&self, sound_specification: PlaySoundSpecification)
Play a sound for this player.
The sound is not played if its location is not charted for this player.
Sourcepub fn print(&self, message: &str, print_settings: Option<PrintSettings>)
pub fn print(&self, message: &str, print_settings: Option<PrintSettings>)
Print text to the chat console.
By default, messages that are identical to a message sent in the last 60 ticks are not printed again.
Sourcepub fn print_entity_statistics(&self, entities: Option<Vec<LuaAny>>)
pub fn print_entity_statistics(&self, entities: Option<Vec<LuaAny>>)
Print entity statistics to the player’s console.
Sourcepub fn print_lua_object_statistics(&self)
pub fn print_lua_object_statistics(&self)
Print LuaObject counts per mod.
Sourcepub fn print_robot_jobs(&self)
pub fn print_robot_jobs(&self)
Print construction robot job counts to the player’s console.
Sourcepub fn remove_alert(&self, filter: AlertFilter)
pub fn remove_alert(&self, filter: AlertFilter)
Removes all alerts matching the given filters or if an empty filters table is given all alerts are removed.
Sourcepub fn request_translation(&self, localised_string: &str) -> u32
pub fn request_translation(&self, localised_string: &str) -> u32
Requests a translation for the given localised string. The on_string_translated event will be fired with the results.
If this player is not connected (see LuaPlayer::connected) the translation will happen next time they connect.
Sourcepub fn request_translations(&self, localised_strings: Vec<&str>) -> Vec<u32>
pub fn request_translations(&self, localised_strings: Vec<&str>) -> Vec<u32>
Requests translation for the given set of localised strings. A on_string_translated event will be fired for each string with the results.
If this player is not connected (see LuaPlayer::connected) the translation will happen next time they connect.
Sourcepub fn set_active_quick_bar_page(&self, page_index: u32, screen_index: u32)
pub fn set_active_quick_bar_page(&self, page_index: u32, screen_index: u32)
Sets which quick bar page is being used for the given screen page.
Sourcepub fn set_controller(&self, params: LuaPlayerSetControllerParams)
pub fn set_controller(&self, params: LuaPlayerSetControllerParams)
Set the controller type of the player.
Setting a player to defines.controllers.editor auto promotes the player to admin and enables cheat mode. Setting a player to defines.controllers.editor also requires the calling player be an admin.
Sourcepub fn set_ending_screen_data(&self, file: Option<&str>, message: &str)
pub fn set_ending_screen_data(&self, file: Option<&str>, message: &str)
Setup the screen to be shown when the game is finished.
Sourcepub fn set_goal_description(
&self,
only_update: Option<bool>,
text: Option<&str>,
)
pub fn set_goal_description( &self, only_update: Option<bool>, text: Option<&str>, )
Set the text in the goal window (top left).
Sourcepub fn set_infinity_inventory_filter(
&self,
filter: Option<InfinityInventoryFilter>,
index: u32,
)
pub fn set_infinity_inventory_filter( &self, filter: Option<InfinityInventoryFilter>, index: u32, )
Sets the filter for this map editor infinity filters at the given index.
Sourcepub fn set_quick_bar_slot(&self, filter: LuaAny, page_index: u8, slot_index: u8)
pub fn set_quick_bar_slot(&self, filter: LuaAny, page_index: u8, slot_index: u8)
Sets the quick bar filter for the given slot. If a LuaItemStack is provided, the slot will be set to that particular item instance if it has extra data, for example a specific blueprint or spidertron remote. Otherwise, it will be set to all items of that prototype, for example iron plates.
Sourcepub fn set_shortcut_available(&self, available: bool, prototype_name: &str)
pub fn set_shortcut_available(&self, available: bool, prototype_name: &str)
Make a custom Lua shortcut available or unavailable.
Sourcepub fn set_shortcut_toggled(&self, prototype_name: &str, toggled: bool)
pub fn set_shortcut_toggled(&self, prototype_name: &str, toggled: bool)
Toggle or untoggle a custom Lua shortcut
Sourcepub fn set_zoom_limits(&self, controller_type: &str, zoom_limits: ZoomLimits)
pub fn set_zoom_limits(&self, controller_type: &str, zoom_limits: ZoomLimits)
Sets the zoom limits for a specific controller type. To reset a controller’s zoom limits to default, pass an empty table for zoom_limits.
Sourcepub fn stack_transfers(
&self,
params: LuaPlayerStackTransfersParams,
) -> Option<Vec<ItemWithQualityCount>>
pub fn stack_transfers( &self, params: LuaPlayerStackTransfersParams, ) -> Option<Vec<ItemWithQualityCount>>
Performs the given transfer action between the source and target as if the player did the action.
This can be paired with defines.events.on_gui_inventory_action to make custom inventory GUIs that act like builtin inventories.
Reach distance is ignored and can be checked using LuaControl::can_reach_entity if wanted.
Sourcepub fn start_selection(&self, position: MapPosition, selection_mode: &str)
pub fn start_selection(&self, position: MapPosition, selection_mode: &str)
Starts selection with selection tool from the specified position. Does nothing if the player’s cursor is not a selection tool.
Sourcepub fn swap_characters(&self, player: LuaAny) -> bool
pub fn swap_characters(&self, player: LuaAny) -> bool
Swaps this player’s character with another player’s character.
Sourcepub fn toggle_map_editor(&self)
pub fn toggle_map_editor(&self)
Toggles this player into or out of the map editor. Does nothing if this player isn’t an admin or if the player doesn’t have permission to use the map editor.
Sourcepub fn unlock_achievement(&self, name: &str)
pub fn unlock_achievement(&self, name: &str)
Unlock the achievements of the given player. This has any effect only when this is the local player, the achievement isn’t unlocked so far and the achievement is of the type “achievement”.
Sourcepub fn unmute_alert(&self, alert_type: &str) -> bool
pub fn unmute_alert(&self, alert_type: &str) -> bool
Unmutes alerts for the given alert category.
Sourcepub fn use_from_cursor(&self, position: MapPosition)
pub fn use_from_cursor(&self, position: MapPosition)
Uses the current item in the cursor if it’s a capsule or does nothing if not.