Skip to main content

LuaPlayer

Struct LuaPlayer 

Source
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

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

Source

pub fn afk_time(&self) -> u32

How many ticks since the last action of this player.

Source

pub fn auto_sort_main_inventory(&self) -> bool

If the main inventory will be auto sorted.

Source

pub fn blueprint_to_setup(&self) -> LuaItemStack

The item stack containing a blueprint to be setup.

Source

pub fn blueprints(&self) -> Vec<LuaRecord>

Records contained in the player’s blueprint library.

Source

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.

Source

pub fn character(&self) -> LuaEntity

The character attached to this player, if any. Returns nil when the player is disconnected (see LuaPlayer::connected).

Source

pub fn chat_color(&self) -> Color

The color used when this player talks in game.

Source

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.

Source

pub fn connected(&self) -> bool

true if the player is currently connected to the game.

Source

pub fn controller_type(&self) -> &str

Source

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.

Source

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.

Source

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

Source

pub fn disable_space_map(&self) -> bool

Set to true to disallow opening the space map and hide the space map button.

Source

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.

Source

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.

Source

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.

Source

pub fn drag_target(&self) -> DragTarget

The wire drag target for this player, if any.

Source

pub fn entity_copy_source(&self) -> LuaEntity

The source entity used during entity settings copy-paste, if any.

Source

pub fn game_view_settings(&self) -> LuaAny

The player’s game view settings.

Source

pub fn gui(&self) -> LuaGui

Source

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.

Source

pub fn hide_locked_prototypes_in_factoriopedia(&self) -> bool

Set to true to hide prototypes in Factoriopedia if they aren’t unlocked yet.

Source

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.

Source

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

The filters for this map editor infinity inventory settings.

Source

pub fn input_method(&self) -> &str

The input method of the player, mouse and keyboard or game controller

Source

pub fn last_online(&self) -> u32

At what tick this player was last online.

Source

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.

Source

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.

Source

pub fn minimap_enabled(&self) -> bool

true if the minimap is visible.

Source

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.

Source

pub fn name(&self) -> &str

The player’s username.

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 online_time(&self) -> u32

How many ticks did this player spend playing this save (all sessions combined).

Source

pub fn opened_self(&self) -> bool

true if the player opened itself. I.e. if they opened the character or god-controller GUI.

Source

pub fn permission_group(&self) -> LuaPermissionGroup

The permission group this player is part of, if any.

Source

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.

Source

pub fn physical_position(&self) -> MapPosition

The current position of this player’s physical controller.

Source

pub fn physical_surface(&self) -> LuaSurface

The surface this player’s physical controller is on.

Source

pub fn physical_surface_index(&self) -> u32

Unique ID associated with the surface this player’s physical controller is currently on.

Source

pub fn physical_vehicle(&self) -> LuaEntity

The current vehicle of this player’s physical controller.

Source

pub fn quick_bar_width(&self) -> u8

Amount of slots one row(page) of quickbar has.

Source

pub fn remove_unfiltered_items(&self) -> bool

If items not included in this map editor infinity inventory filters should be removed.

Source

pub fn render_mode(&self) -> &str

The render mode of the player, like map or zoom to world.

Source

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.

Source

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.

Source

pub fn show_on_map(&self) -> bool

If true, circle and name of given player is rendered on the map/chart.

Source

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.

Source

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

All SpiderVehicles currently selected by the player, if they are holding a spidertron remote.

Source

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.

Source

pub fn tag(&self) -> &str

The tag that is shown after the player in chat, on the map and above multiplayer selection rectangles.

Source

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.

Source

pub fn undo_redo_stack(&self) -> LuaUndoRedoStack

The undo and redo stack for this player.

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

Source

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.

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

Source

pub fn add_alert(&self, entity: LuaEntity, type: &str)

Adds an alert to this player for the given entity of the given alert type.

Source

pub fn add_custom_alert( &self, entity: LuaEntity, icon: SignalID, message: &str, show_on_map: bool, )

Adds a custom alert to this player.

Source

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.

Source

pub fn add_recipe_notification(&self, recipe: LuaAny)

Adds the given recipe to the list of recipe notifications for this player.

Source

pub fn add_to_clipboard(&self, blueprint: LuaItemStack)

Adds the given blueprint to this player’s clipboard queue.

Source

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.

Source

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.

Source

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.

Source

pub fn clear_console(&self)

Clear the chat console.

Source

pub fn clear_cursor(&self) -> bool

Invokes the “clear cursor” action on the player as if the user pressed it.

Source

pub fn clear_inventory_highlights(&self)

Clears the blinking of the inventory based on insertion of items

Source

pub fn clear_local_flying_texts(&self)

Clear any active flying texts for this player.

Source

pub fn clear_recipe_notification(&self, recipe: LuaAny)

Clears the given recipe from the list of recipe notifications for this player.

Source

pub fn clear_recipe_notifications(&self)

Clears all recipe notifications for this player.

Source

pub fn clear_selection(&self)

Clears the player’s selection tool selection position.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn disable_alert(&self, alert_type: &str) -> bool

Disables alerts for the given alert category.

Source

pub fn disable_recipe_groups(&self)

Disable recipe groups.

Source

pub fn disable_recipe_subgroups(&self)

Disable recipe subgroups.

Source

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.

Source

pub fn drag_wire(&self, params: LuaPlayerDragWireParams) -> bool

Start/end wire dragging at the specified location, wire type is based on the cursor contents

Source

pub fn enable_alert(&self, alert_type: &str) -> bool

Enables alerts for the given alert category.

Source

pub fn enable_recipe_groups(&self)

Enable recipe groups.

Source

pub fn enable_recipe_subgroups(&self)

Enable recipe subgroups.

Source

pub fn enter_space_platform(&self, space_platform: LuaSpacePlatform) -> bool

Enters the given space platform if possible.

Source

pub fn exit_cutscene(&self)

Exit the current cutscene. Errors if not in a cutscene.

Source

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.

Source

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.

Source

pub fn get_alerts(&self, filter: AlertFilter) -> LuaAny

Get all alerts matching the given filters, or all alerts if no filters are given.

Source

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.

Source

pub fn get_goal_description(&self) -> &str

Get the current goal description, as a localised string.

Source

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.

Source

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.

Source

pub fn get_recipe_notifications(&self) -> Vec<LuaRecipePrototype>

Get all recipes that currently have recipe notifications for this player.

Source

pub fn is_alert_enabled(&self, alert_type: &str) -> bool

If the given alert type is currently enabled.

Source

pub fn is_alert_muted(&self, alert_type: &str) -> bool

If the given alert type is currently muted.

Source

pub fn is_shortcut_available(&self, prototype_name: &str) -> bool

Is a custom Lua shortcut currently available?

Source

pub fn is_shortcut_toggled(&self, prototype_name: &str) -> bool

Is a custom Lua shortcut currently toggled?

Source

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.

Source

pub fn land_on_planet(&self) -> bool

Ejects this player from the current space platform and lands on the current planet.

Source

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.

Source

pub fn mute_alert(&self, alert_type: &str) -> bool

Mutes alerts for the given alert category.

Source

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.

Source

pub fn play_music(&self, music_specification: PlayMusicSpecification)

Play a music track for this player.

Source

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.

Source

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.

Source

pub fn print_entity_statistics(&self, entities: Option<Vec<LuaAny>>)

Print entity statistics to the player’s console.

Source

pub fn print_lua_object_statistics(&self)

Print LuaObject counts per mod.

Source

pub fn print_robot_jobs(&self)

Print construction robot job counts to the player’s console.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_ending_screen_data(&self, file: Option<&str>, message: &str)

Setup the screen to be shown when the game is finished.

Source

pub fn set_goal_description( &self, only_update: Option<bool>, text: Option<&str>, )

Set the text in the goal window (top left).

Source

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.

Source

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.

Source

pub fn set_shortcut_available(&self, available: bool, prototype_name: &str)

Make a custom Lua shortcut available or unavailable.

Source

pub fn set_shortcut_toggled(&self, prototype_name: &str, toggled: bool)

Toggle or untoggle a custom Lua shortcut

Source

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.

Source

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.

Source

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.

Source

pub fn swap_characters(&self, player: LuaAny) -> bool

Swaps this player’s character with another player’s character.

Source

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.

Source

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

Source

pub fn unmute_alert(&self, alert_type: &str) -> bool

Unmutes alerts for the given alert category.

Source

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.

Trait Implementations§

Source§

impl Clone for LuaPlayer

Source§

fn clone(&self) -> LuaPlayer

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 LuaPlayer

Source§

impl Debug for LuaPlayer

Source§

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

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

impl Default for LuaPlayer

Source§

fn default() -> LuaPlayer

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

impl Eq for LuaPlayer

Source§

impl From<LuaPlayer> for LuaAny

Source§

fn from(_: LuaPlayer) -> Self

Converts to this type from the input type.
Source§

impl LuaObject for LuaPlayer

Source§

impl PartialEq for LuaPlayer

Source§

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

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.