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=…, final_transition_time=…, chart_mode_cutoff=…} | Set the controller type of the player. |
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. |
clean_cursor() → boolean | Invokes the "clean 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 of alert | Gets all alerts matching the given filters or if no filters are given all alerts are returned. |
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=…} → boolean | Plays a sound for this player |
get_associated_characters() → array of 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=…, color=…, time_to_live=…, speed=…} | Spawn a 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 shortcut currently toggled? |
is_shortcut_available(prototype_name) → boolean | Is a custom shortcut currently available? |
set_shortcut_toggled(prototype_name, toggled) | Toggle or untoggle a custom shortcut |
set_shortcut_available(prototype_name, available) | Make a custom 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. |
character :: LuaEntity [RW] | The character attached to this player, or nil if no character. |
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] | |
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 [RW] | 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 [R] | |
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. |
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? |
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).
Set the controller type of the player.
type
is
defines.controllers.character, ignored otherwise.type
is defines.controllers.cutscene. Each waypoint is a table:
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.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.Disable 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 "clean 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.
Gets all alerts matching the given filters or if no filters are given all alerts are returned.
A mapping of surface index to an array of arrays of alerts indexed by the alert type. An alert is a table:
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.
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 a flying text that is only visible to this player.
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 shortcut currently toggled?
Is a custom 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.
The character attached to this player, or nil
if no character.
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 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.
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.
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.