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.
set_ending_screen_data(message, file) | Setup the screen to be shown when the game is finished. |
print(message, color) | Print text to the chat console. |
clear_console() | Clear the chat console. |
get_goal_description() → LocalisedString | Get the current goal description, as a localised string. |
set_goal_description(text, only_update) | Set the text in the goal window (top left). |
set_controller{type = …, character = …, waypoints = …, start_position = …, start_zoom = …, final_transition_time = …, chart_mode_cutoff = …} | Set the controller type of the player. |
drag_wire{position = …} → boolean | Start/end wire dragging at the specified location, wire type is based on the cursor contents |
disable_recipe_groups() | Disable recipe groups. |
enable_recipe_groups() | Enable recipe groups. |
disable_recipe_subgroups() | Disable recipe subgroups. |
enable_recipe_subgroups() | Enable recipe subgroups. |
print_entity_statistics(entities) | Print entity statistics to the player's console. |
print_robot_jobs() | Print construction robot job counts to the players console. |
print_lua_object_statistics() | Print LuaObject counts per mod. |
log_active_entity_chunk_counts() | Logs a dictionary of chunks -> active entities for the surface this player is on. |
log_active_entity_counts() | Logs a dictionary of active entities -> count for the surface this player is on. |
unlock_achievement(name) | Unlock the achievements of the given player. |
clear_cursor() → boolean | Invokes the "clear cursor" action on the player as if the user pressed it. |
create_character(character) → boolean | Creates and attaches a character entity to this player. |
add_alert(entity, type) | Adds an alert to this player for the given entity of the given alert type. |
add_custom_alert(entity, icon, message, show_on_map) | Adds a custom alert to this player. |
remove_alert{entity = …, prototype = …, position = …, type = …, surface = …, icon = …, message = …} | Removes all alerts matching the given filters or if an empty filters table is given all alerts are removed. |
get_alerts{entity = …, prototype = …, position = …, type = …, surface = …} → dictionary[uint → dictionary[defines.alert_type → array[Alert]]] | Get all alerts matching the given filters, or all alerts if no filters are given. |
mute_alert(alert_type) → boolean | Mutes alerts for the given alert category. |
unmute_alert(alert_type) → boolean | Unmutes alerts for the given alert category. |
is_alert_muted(alert_type) → boolean | If the given alert type is currently muted. |
enable_alert(alert_type) → boolean | Enables alerts for the given alert category. |
disable_alert(alert_type) → boolean | Disables alerts for the given alert category. |
is_alert_enabled(alert_type) → boolean | If the given alert type is currently enabled. |
pipette_entity(entity) → boolean | Invokes the "smart pipette" action on the player as if the user pressed it. |
can_place_entity{name = …, position = …, direction = …} → boolean | Checks if this player can build the give entity at the given location on the surface the player is on. |
can_build_from_cursor{position = …, direction = …, alt = …, terrain_building_size = …, skip_fog_of_war = …} → boolean | Checks if this player can build what ever is in the cursor on the surface the player is on. |
build_from_cursor{position = …, direction = …, alt = …, terrain_building_size = …, skip_fog_of_war = …} | Builds what ever is in the cursor on the surface the player is on. |
use_from_cursor(position) | Uses the current item in the cursor if it's a capsule or does nothing if not. |
play_sound{path = …, position = …, volume_modifier = …, override_sound_type = …} | Play a sound for this player. |
get_associated_characters() → array[LuaEntity] | The characters associated with this player. |
associate_character(character) | Associates a character with this player. |
disassociate_character(character) | Disassociates a character from this player. |
create_local_flying_text{text = …, position = …, create_at_cursor = …, color = …, time_to_live = …, speed = …} | Spawn flying text that is only visible to this player. |
get_quick_bar_slot(index) → LuaItemPrototype | Gets the quick bar filter for the given slot or nil . |
set_quick_bar_slot(index, filter) | Sets the quick bar filter for the given slot. |
get_active_quick_bar_page(index) → uint8 | Gets which quick bar page is being used for the given screen page or nil if not known. |
set_active_quick_bar_page(screen_index, page_index) | Sets which quick bar page is being used for the given screen page. |
jump_to_cutscene_waypoint(waypoint_index) | Jump to the specified cutscene waypoint. |
exit_cutscene() | Exit the current cutscene. |
open_map(position, scale) | Queues a request to open the map at the specified position. |
zoom_to_world(position, scale) | Queues a request to zoom to world at the specified position. |
close_map() | Queues request to switch to the normal game view from the map or zoom to world view. |
is_shortcut_toggled(prototype_name) → boolean | Is a custom Lua shortcut currently toggled? |
is_shortcut_available(prototype_name) → boolean | Is a custom Lua shortcut currently available? |
set_shortcut_toggled(prototype_name, toggled) | Toggle or untoggle a custom Lua shortcut |
set_shortcut_available(prototype_name, available) | Make a custom Lua shortcut available or unavailable. |
connect_to_server{address = …, name = …, description = …, password = …} | Asks the player if they would like to connect to the given server. |
toggle_map_editor() | Toggles this player into or out of the map editor. |
request_translation(localised_string) → boolean | Requests a translation for the given localised string. |
get_infinity_inventory_filter(index) → 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. |
set_infinity_inventory_filter(index, filter) | Sets the filter for this map editor infinity filters at the given index. |
clear_recipe_notifications() | Clears all recipe notifications for this player. |
add_recipe_notification(recipe) | Adds the given recipe to the list of recipe notifications for this player. |
add_to_clipboard(blueprint) | Adds the given blueprint to this player's clipboard queue. |
activate_paste() | Gets a copy of the currently selected blueprint in the clipboard queue into the player's cursor, as if the player activated Paste. |
start_selection(position, selection_mode) | Starts selection with selection tool from the specified position. |
clear_selection() | Clears the players selection tool selection position. |
character :: LuaEntity [RW] | The character attached to this player, or nil if no character. |
cutscene_character :: LuaEntity [R] | When in a cutscene; the character this player would be using once the cutscene is over. |
index :: uint [R] | This player's index in LuaGameScript::players. |
gui :: LuaGui [R] | |
opened_self :: boolean [R] | true if the player opened itself. |
controller_type :: defines.controllers [R] | |
stashed_controller_type :: defines.controllers [R] | The stashed controller type or nil if no controller is stashed. |
game_view_settings :: GameViewSettings [RW] | The player's game view settings. |
minimap_enabled :: boolean [RW] | true if the minimap is visible. |
color :: Color [RW] | The color associated with the player. |
chat_color :: Color [RW] | The color used when this player talks in game. |
name :: string [R] | The player's username. |
tag :: string [RW] | The tag that is shown after the player in chat and on the map. |
connected :: boolean [R] | true if the player is currently connected to the game. |
admin :: boolean [RW] | true if the player is an admin. |
entity_copy_source :: LuaEntity [R] | The source entity used during entity settings copy-paste if any. |
afk_time :: uint [R] | How many ticks since the last action of this player |
online_time :: uint [R] | How many ticks did this player spend playing this save (all sessions combined) |
last_online :: uint [R] | At what tick this player was last online. |
permission_group :: LuaPermissionGroup [RW] | The permission group this player is part of or nil if not part of any group. |
mod_settings :: LuaCustomTable[string → ModSetting] [R] | Gets the current per-player settings for the this player, indexed by prototype name. |
ticks_to_respawn :: uint [RW] | The number of ticks until this player will respawn or nil if not waiting to respawn. |
display_resolution :: DisplayResolution [R] | The display resolution for this player. |
display_scale :: double [R] | The display scale for this player. |
blueprint_to_setup :: LuaItemStack [R] | The item stack containing a blueprint to be setup. |
render_mode :: defines.render_mode [R] | The render mode of the player, like map or zoom to world. |
spectator :: boolean [RW] | 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. |
remove_unfiltered_items :: boolean [RW] | If items not included in this map editor infinity inventory filters should be removed. |
infinity_inventory_filters :: array[InfinityInventoryFilter] [RW] | The filters for this map editor infinity inventory settings. |
auto_sort_main_inventory :: boolean [R] | If the main inventory will be auto sorted. |
hand_location :: ItemStackLocation [RW] | The original location of the item in the cursor, marked with a hand. |
zoom :: double [W] | The player's zoom-level. |
map_view_settings :: MapViewSettings [W] | The player's map view settings. |
valid :: boolean [R] | Is this object valid? |
object_name :: string [R] | The class name of this object. |
help() → string | All methods and properties that this object supports. |
Setup the screen to be shown when the game is finished.
Print text to the chat console.
Clear the chat console.
Get the current goal description, as a localised string.
Set the text in the goal window (top left).
\n
. Passing an empty
string or omitting this parameter entirely will make the goal window disappear.Set the controller type of the player.
type
is
defines.controllers.character, ignored otherwise.type
is defines.controllers.cutscene.type
is defines.controllers.cutscene,
the cutscene will start at this position. If not given the start position will be the player position.type
is defines.controllers.cutscene,
the cutscene will start at this zoom level. If not given the start zoom will be the players zoom.type
is defines.controllers.cutscene,
it is the time in ticks it will take for the camera to pan from the final waypoint back to the starting
position. If not given the camera will not pan back to the start position/zoom.type
is defines.controllers.cutscene,
the game will switch to chart-mode (map zoomed out) rendering when the zoom level is less than this value.Start/end wire dragging at the specified location, wire type is based on the cursor contents
true
if the action did somethingDisable recipe groups.
Enable recipe groups.
Disable recipe subgroups.
Enable recipe subgroups.
Print entity statistics to the player's console.
Print construction robot job counts to the players console.
Print LuaObject counts per mod.
Logs a dictionary of chunks -> active entities for the surface this player is on.
Logs a dictionary of active entities -> count for the surface this player is on.
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".
Invokes the "clear cursor" action on the player as if the user pressed it.
Creates and attaches a character entity to this player.
Adds an alert to this player for the given entity of the given alert type.
Adds a custom alert to this player.
Removes all alerts matching the given filters or if an empty filters table is given all alerts are removed.
Get all alerts matching the given filters, or all alerts if no filters are given.
Mutes alerts for the given alert category.
Unmutes alerts for the given alert category.
Enables alerts for the given alert category.
Disables alerts for the given alert category.
Invokes the "smart pipette" action on the player as if the user pressed it.
Checks if this player can build the give entity at the given location on the surface the player is on.
Checks if this player can build what ever is in the cursor on the surface the player is on.
Builds what ever is in the cursor on the surface the player is on.
Uses the current item in the cursor if it's a capsule or does nothing if not.
Play a sound for this player.
The characters associated with this player.
Associates a character with this player.
Disassociates a character from this player.
This is functionally the same as setting LuaEntity::associated_player to nil
.
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.
true
, the flying text is created at the player's cursor.
Defaults to false
.80
.speed
is set and the text is longer than 25 characters, its time_to_live
and speed
are
dynamically adjusted to give players more time to read it. Gets the quick bar filter for the given slot or nil
.
Sets the quick bar filter for the given slot.
Gets which quick bar page is being used for the given screen page or nil
if not known.
Sets which quick bar page is being used for the given screen page.
Jump to the specified cutscene waypoint. Only works when the player is viewing a cutscene.
Exit the current cutscene. Errors if not in a cutscene.
Queues request to switch to the normal game view from the map or zoom to world view. Render mode change requests are processed before rendering of the next frame.
Is a custom Lua shortcut currently toggled?
Is a custom Lua shortcut currently available?
Asks the player if they would like to connect to the given server.
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.
Requests a translation for the given localised string. If the request is successful the on_string_translated event will be fired at a later time with the results.
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.
Sets the filter for this map editor infinity filters at the given index.
Clears all recipe notifications for this player.
Adds the given recipe to the list of recipe notifications for this player.
Adds the given blueprint to this player's clipboard queue.
Gets a copy of the currently selected blueprint in the clipboard queue into the player's cursor, as if the player activated Paste.
Starts selection with selection tool from the specified position. Does nothing if the players cursor is not a selection tool.
Clears the players selection tool selection position.
The character attached to this player, or nil
if no character.
nil
when the player is disconnected (see LuaPlayer::connected).
When in a cutscene; the character this player would be using once the cutscene is over.
nil
when the player is disconnected (see LuaPlayer::connected).
This player's index in LuaGameScript::players.
true
if the player opened itself. I.e. if they opened the character or god-controller GUI.
The stashed controller type or nil
if no controller is stashed.
The player's game view settings.
true
if the minimap is visible.
The color associated with the player. This will be used to tint the player's character as well as their buildings and vehicles.
The color used when this player talks in game.
The player's username.
The tag that is shown after the player in chat and on the map.
true
if the player is currently connected to the game.
true
if the player is an admin.
The source entity used during entity settings copy-paste if any.
nil
if there isn't currently a source entity.
How many ticks since the last action of this player
How many ticks did this player spend playing this save (all sessions combined)
At what tick this player was last online.
The permission group this player is part of or nil
if not part of any group.
Gets the current per-player settings for the this player, indexed by prototype name. Returns the same structure as LuaSettings::get_player_settings.
The number of ticks until this player will respawn or nil
if not waiting to respawn.
nil
to immediately respawn the player.The display resolution for this player.
The display scale for this player.
The item stack containing a blueprint to be setup.
The render mode of the player, like map or zoom to world. The render mode can be set using LuaPlayer::open_map, LuaPlayer::zoom_to_world and LuaPlayer::close_map.
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.
If items not included in this map editor infinity inventory filters should be removed.
The filters for this map editor infinity inventory settings.
If the main inventory will be auto sorted.
The original location of the item in the cursor, marked with a hand. When writing, the specified inventory slot must be empty and the cursor stack must not be empty.
The player's zoom-level.
The player's map view settings. To write to this, use a table containing the fields that should be changed.