Main toplevel type, provides access to most of the API though its members. An instance of LuaGameScript is available as the global object named game
.
set_game_state{game_finished?=…, player_won?=…, next_level?=…, can_continue?=…, victorious_force?=…} |
Set scenario state. |
|
Set scenario state. |
||
reset_game_state() |
Reset scenario state (game_finished, player_won, etc.). |
|
Reset scenario state (game_finished, player_won, etc.). |
||
get_entity_by_tag(tag) | → LuaEntity? |
|
show_message_dialog{text=…, image?=…, point_to?=…, style?=…, wrapper_frame_style?=…} |
Show an in-game message dialog. |
|
Show an in-game message dialog. |
||
is_demo() | → boolean |
Is this the demo version of Factorio? |
Is this the demo version of Factorio? |
||
reload_script() |
Forces a reload of the scenario script from the original scenario location. |
|
Forces a reload of the scenario script from the original scenario location. |
||
reload_mods() |
Forces a reload of all mods. |
|
Forces a reload of all mods. |
||
save_atlas() |
Saves the current configuration of Atlas to a file. |
|
Saves the current configuration of Atlas to a file. |
||
check_consistency() |
Run internal consistency checks. |
|
Run internal consistency checks. |
||
regenerate_entity(entities) |
Regenerate autoplacement of some entities on all surfaces. |
|
Regenerate autoplacement of some entities on all surfaces. |
||
take_screenshot{player?=…, by_player?=…, surface?=…, position?=…, resolution?=…, zoom?=…, path?=…, show_gui?=…, show_entity_info?=…, show_cursor_building_preview?=…, anti_alias?=…, quality?=…, allow_in_replay?=…, daytime?=…, water_tick?=…, force_render?=…} |
Take a screenshot of the game and save it to the |
|
Take a screenshot of the game and save it to the |
||
set_wait_for_screenshots_to_finish() |
Forces the screenshot saving system to wait until all queued screenshots have been written to disk. |
|
Forces the screenshot saving system to wait until all queued screenshots have been written to disk. |
||
take_technology_screenshot{force?=…, path?=…, by_player?=…, selected_technology?=…, skip_disabled?=…, quality?=…} |
Take a screenshot of the technology screen and save it to the |
|
Take a screenshot of the technology screen and save it to the |
||
table_to_json(data) | → string |
Convert a table to a JSON string |
Convert a table to a JSON string |
||
json_to_table(json) | → AnyBasic? |
Convert a JSON string to a table. |
Convert a JSON string to a table. |
||
write_file(filename, data, append?, for_player?) |
Write a file to the |
|
Write a file to the |
||
remove_path(path) |
Remove a file or directory in the |
|
Remove a file or directory in the |
||
remove_offline_players(players?) |
Remove players who are currently not connected from the map. |
|
Remove players who are currently not connected from the map. |
||
force_crc() |
Force a CRC check. |
|
Force a CRC check. |
||
create_force(force) | → LuaForce |
Create a new force. |
Create a new force. |
||
merge_forces(source, destination) |
Marks two forces to be merged together. |
|
Marks two forces to be merged together. |
||
create_surface(name, settings?) | → LuaSurface |
Create a new surface. |
Create a new surface. |
||
server_save(name?) |
Instruct the server to save the map. |
|
Instruct the server to save the map. |
||
auto_save(name?) |
Instruct the game to perform an auto-save. |
|
Instruct the game to perform an auto-save. |
||
delete_surface(surface) |
Deletes the given surface and all entities on it. |
|
Deletes the given surface and all entities on it. |
||
disable_replay() |
Disables replay saving for the current save file. |
|
Disables replay saving for the current save file. |
||
disable_tutorial_triggers() |
Disables tutorial triggers, that unlock new tutorials and show notices about unlocked tutorials. |
|
Disables tutorial triggers, that unlock new tutorials and show notices about unlocked tutorials. |
||
direction_to_string(direction) |
Converts the given direction into the string version of the direction. |
|
Converts the given direction into the string version of the direction. |
||
print(message, color?) |
Print text to the chat console all players. |
|
Print text to the chat console all players. |
||
create_random_generator(seed?) | → LuaRandomGenerator |
Creates a deterministic standalone random generator with the given seed or if a seed is not provided the initial map seed is used. |
Creates a deterministic standalone random generator with the given seed or if a seed is not provided the initial map seed is used. |
||
check_prototype_translations() |
Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect. |
|
Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect. |
||
play_sound{path=…, position?=…, volume_modifier?=…, override_sound_type?=…} |
Play a sound for every player in the game. |
|
Play a sound for every player in the game. |
||
is_valid_sound_path(sound_path) | → boolean |
Checks if the given SoundPath is valid. |
Checks if the given SoundPath is valid. |
||
is_valid_sprite_path(sprite_path) | → boolean |
Checks if the given SpritePath is valid and contains a loaded sprite. |
Checks if the given SpritePath is valid and contains a loaded sprite. |
||
kick_player(player, reason?) |
Kicks the given player from this multiplayer game. |
|
Kicks the given player from this multiplayer game. |
||
ban_player(player, reason?) |
Bans the given player from this multiplayer game. |
|
Bans the given player from this multiplayer game. |
||
unban_player(player) |
Unbans the given player from this multiplayer game. |
|
Unbans the given player from this multiplayer game. |
||
purge_player(player) |
Purges the given players messages from the game. |
|
Purges the given players messages from the game. |
||
mute_player(player) |
Mutes the given player. |
|
Mutes the given player. |
||
unmute_player(player) |
Unmutes the given player. |
|
Unmutes the given player. |
||
count_pipe_groups() |
Counts how many distinct groups of pipes exist in the world. |
|
Counts how many distinct groups of pipes exist in the world. |
||
is_multiplayer() | → boolean |
Is the map loaded is multiplayer? |
Is the map loaded is multiplayer? |
||
get_active_entities_count(surface?) | → uint |
Gets the number of entities that are active (updated each tick). |
Gets the number of entities that are active (updated each tick). |
||
get_map_exchange_string() | → string |
Gets the map exchange string for the map generation settings that were used to create this map. |
Gets the map exchange string for the map generation settings that were used to create this map. |
||
parse_map_exchange_string(map_exchange_string) | → MapExchangeStringData |
Convert a map exchange string to map gen settings and map settings. |
Convert a map exchange string to map gen settings and map settings. |
||
get_train_stops{name?=…, surface?=…, force?=…} | → array[LuaEntity] |
Gets train stops matching the given filters. |
Gets train stops matching the given filters. |
||
get_player(player) | → LuaPlayer? |
Gets the given player or returns |
Gets the given player or returns |
||
get_surface(surface) | → LuaSurface? |
Gets the given surface or returns |
Gets the given surface or returns |
||
create_profiler(stopped?) | → LuaProfiler |
Creates a LuaProfiler, which is used for measuring script performance. |
Creates a LuaProfiler, which is used for measuring script performance. |
||
evaluate_expression(expression, variables?) | → double |
Evaluate an expression, substituting variables as provided. |
Evaluate an expression, substituting variables as provided. |
||
get_filtered_entity_prototypes(filters) | → LuaCustomTable[string → LuaEntityPrototype] |
Returns a dictionary of all LuaEntityPrototypes that fit the given filters. |
Returns a dictionary of all LuaEntityPrototypes that fit the given filters. |
||
get_filtered_item_prototypes(filters) | → LuaCustomTable[string → LuaItemPrototype] |
Returns a dictionary of all LuaItemPrototypes that fit the given filters. |
Returns a dictionary of all LuaItemPrototypes that fit the given filters. |
||
get_filtered_equipment_prototypes(filters) | → LuaCustomTable[string → LuaEquipmentPrototype] |
Returns a dictionary of all LuaEquipmentPrototypes that fit the given filters. |
Returns a dictionary of all LuaEquipmentPrototypes that fit the given filters. |
||
get_filtered_mod_setting_prototypes(filters) | → LuaCustomTable[string → LuaModSettingPrototype] |
Returns a dictionary of all LuaModSettingPrototypes that fit the given filters. |
Returns a dictionary of all LuaModSettingPrototypes that fit the given filters. |
||
get_filtered_achievement_prototypes(filters) | → LuaCustomTable[string → LuaAchievementPrototype] |
Returns a dictionary of all LuaAchievementPrototypes that fit the given filters. |
Returns a dictionary of all LuaAchievementPrototypes that fit the given filters. |
||
get_filtered_tile_prototypes(filters) | → LuaCustomTable[string → LuaTilePrototype] |
Returns a dictionary of all LuaTilePrototypes that fit the given filters. |
Returns a dictionary of all LuaTilePrototypes that fit the given filters. |
||
get_filtered_decorative_prototypes(filters) | → LuaCustomTable[string → LuaDecorativePrototype] |
Returns a dictionary of all LuaDecorativePrototypes that fit the given filters. |
Returns a dictionary of all LuaDecorativePrototypes that fit the given filters. |
||
get_filtered_fluid_prototypes(filters) | → LuaCustomTable[string → LuaFluidPrototype] |
Returns a dictionary of all LuaFluidPrototypes that fit the given filters. |
Returns a dictionary of all LuaFluidPrototypes that fit the given filters. |
||
get_filtered_recipe_prototypes(filters) | → LuaCustomTable[string → LuaRecipePrototype] |
Returns a dictionary of all LuaRecipePrototypes that fit the given filters. |
Returns a dictionary of all LuaRecipePrototypes that fit the given filters. |
||
get_filtered_technology_prototypes(filters) | → LuaCustomTable[string → LuaTechnologyPrototype] |
Returns a dictionary of all LuaTechnologyPrototypes that fit the given filters. |
Returns a dictionary of all LuaTechnologyPrototypes that fit the given filters. |
||
create_inventory(size) | → LuaInventory |
Creates an inventory that is not owned by any game object. |
Creates an inventory that is not owned by any game object. |
||
get_script_inventories(mod?) | → dictionary[string → array[LuaInventory]] |
Gets the inventories created through LuaGameScript::create_inventory |
Gets the inventories created through LuaGameScript::create_inventory |
||
reset_time_played() |
Resets the amount of time played for this map. |
|
Resets the amount of time played for this map. |
||
encode_string(string) | → string? |
Deflates and base64 encodes the given string. |
Deflates and base64 encodes the given string. |
||
decode_string(string) | → string? |
Base64 decodes and inflates the given string. |
Base64 decodes and inflates the given string. |
||
object_name [R] | :: string |
This object's name. |
This object's name. |
||
player [R] | :: LuaPlayer? |
This property is only populated inside custom command handlers and when writing Lua console commands. |
This property is only populated inside custom command handlers and when writing Lua console commands. |
||
players [R] | :: LuaCustomTable[uint or string → LuaPlayer] |
Get a table of all the players that currently exist. |
Get a table of all the players that currently exist. |
||
map_settings [R] | :: MapSettings |
The currently active set of map settings. |
The currently active set of map settings. |
||
difficulty_settings [R] | :: DifficultySettings |
The currently active set of difficulty settings. |
The currently active set of difficulty settings. |
||
difficulty [R] | :: defines.difficulty |
Current scenario difficulty. |
Current scenario difficulty. |
||
forces [R] | :: LuaCustomTable[uint or string → LuaForce] |
Get a table of all the forces that currently exist. |
Get a table of all the forces that currently exist. |
||
entity_prototypes [R] | :: LuaCustomTable[string → LuaEntityPrototype] |
A dictionary containing every LuaEntityPrototype indexed by |
A dictionary containing every LuaEntityPrototype indexed by |
||
item_prototypes [R] | :: LuaCustomTable[string → LuaItemPrototype] |
A dictionary containing every LuaItemPrototype indexed by |
A dictionary containing every LuaItemPrototype indexed by |
||
fluid_prototypes [R] | :: LuaCustomTable[string → LuaFluidPrototype] |
A dictionary containing every LuaFluidPrototype indexed by |
A dictionary containing every LuaFluidPrototype indexed by |
||
tile_prototypes [R] | :: LuaCustomTable[string → LuaTilePrototype] |
A dictionary containing every LuaTilePrototype indexed by |
A dictionary containing every LuaTilePrototype indexed by |
||
equipment_prototypes [R] | :: LuaCustomTable[string → LuaEquipmentPrototype] |
A dictionary containing every LuaEquipmentPrototype indexed by |
A dictionary containing every LuaEquipmentPrototype indexed by |
||
damage_prototypes [R] | :: LuaCustomTable[string → LuaDamagePrototype] |
A dictionary containing every LuaDamagePrototype indexed by |
A dictionary containing every LuaDamagePrototype indexed by |
||
virtual_signal_prototypes [R] | :: LuaCustomTable[string → LuaVirtualSignalPrototype] |
A dictionary containing every LuaVirtualSignalPrototype indexed by |
A dictionary containing every LuaVirtualSignalPrototype indexed by |
||
equipment_grid_prototypes [R] | :: LuaCustomTable[string → LuaEquipmentGridPrototype] |
A dictionary containing every LuaEquipmentGridPrototype indexed by |
A dictionary containing every LuaEquipmentGridPrototype indexed by |
||
recipe_prototypes [R] | :: LuaCustomTable[string → LuaRecipePrototype] |
A dictionary containing every LuaRecipePrototype indexed by |
A dictionary containing every LuaRecipePrototype indexed by |
||
technology_prototypes [R] | :: LuaCustomTable[string → LuaTechnologyPrototype] |
A dictionary containing every LuaTechnologyPrototype indexed by |
A dictionary containing every LuaTechnologyPrototype indexed by |
||
decorative_prototypes [R] | :: LuaCustomTable[string → LuaDecorativePrototype] |
A dictionary containing every LuaDecorativePrototype indexed by |
A dictionary containing every LuaDecorativePrototype indexed by |
||
particle_prototypes [R] | :: LuaCustomTable[string → LuaParticlePrototype] |
A dictionary containing every LuaParticlePrototype indexed by |
A dictionary containing every LuaParticlePrototype indexed by |
||
autoplace_control_prototypes [R] | :: LuaCustomTable[string → LuaAutoplaceControlPrototype] |
A dictionary containing every LuaAutoplaceControlPrototype indexed by |
A dictionary containing every LuaAutoplaceControlPrototype indexed by |
||
noise_layer_prototypes [R] | :: LuaCustomTable[string → LuaNoiseLayerPrototype] |
A dictionary containing every LuaNoiseLayerPrototype indexed by |
A dictionary containing every LuaNoiseLayerPrototype indexed by |
||
mod_setting_prototypes [R] | :: LuaCustomTable[string → LuaModSettingPrototype] |
A dictionary containing every LuaModSettingPrototype indexed by |
A dictionary containing every LuaModSettingPrototype indexed by |
||
custom_input_prototypes [R] | :: LuaCustomTable[string → LuaCustomInputPrototype] |
A dictionary containing every LuaCustomInputPrototype indexed by |
A dictionary containing every LuaCustomInputPrototype indexed by |
||
ammo_category_prototypes [R] | :: LuaCustomTable[string → LuaAmmoCategoryPrototype] |
A dictionary containing every LuaAmmoCategoryPrototype indexed by |
A dictionary containing every LuaAmmoCategoryPrototype indexed by |
||
named_noise_expressions [R] | :: LuaCustomTable[string → LuaNamedNoiseExpression] |
A dictionary containing every LuaNamedNoiseExpression indexed by |
A dictionary containing every LuaNamedNoiseExpression indexed by |
||
item_subgroup_prototypes [R] | :: LuaCustomTable[string → LuaGroup] |
A dictionary containing every ItemSubgroup indexed by |
A dictionary containing every ItemSubgroup indexed by |
||
item_group_prototypes [R] | :: LuaCustomTable[string → LuaGroup] |
A dictionary containing every ItemGroup indexed by |
A dictionary containing every ItemGroup indexed by |
||
fuel_category_prototypes [R] | :: LuaCustomTable[string → LuaFuelCategoryPrototype] |
A dictionary containing every LuaFuelCategoryPrototype indexed by |
A dictionary containing every LuaFuelCategoryPrototype indexed by |
||
resource_category_prototypes [R] | :: LuaCustomTable[string → LuaResourceCategoryPrototype] |
A dictionary containing every LuaResourceCategoryPrototype indexed by |
A dictionary containing every LuaResourceCategoryPrototype indexed by |
||
achievement_prototypes [R] | :: LuaCustomTable[string → LuaAchievementPrototype] |
A dictionary containing every LuaAchievementPrototype indexed by |
A dictionary containing every LuaAchievementPrototype indexed by |
||
module_category_prototypes [R] | :: LuaCustomTable[string → LuaModuleCategoryPrototype] |
A dictionary containing every LuaModuleCategoryPrototype indexed by |
A dictionary containing every LuaModuleCategoryPrototype indexed by |
||
equipment_category_prototypes [R] | :: LuaCustomTable[string → LuaEquipmentCategoryPrototype] |
A dictionary containing every LuaEquipmentCategoryPrototype indexed by |
A dictionary containing every LuaEquipmentCategoryPrototype indexed by |
||
trivial_smoke_prototypes [R] | :: LuaCustomTable[string → LuaTrivialSmokePrototype] |
A dictionary containing every LuaTrivialSmokePrototype indexed by |
A dictionary containing every LuaTrivialSmokePrototype indexed by |
||
shortcut_prototypes [R] | :: LuaCustomTable[string → LuaShortcutPrototype] |
A dictionary containing every LuaShortcutPrototype indexed by |
A dictionary containing every LuaShortcutPrototype indexed by |
||
recipe_category_prototypes [R] | :: LuaCustomTable[string → LuaRecipeCategoryPrototype] |
A dictionary containing every LuaRecipeCategoryPrototype indexed by |
A dictionary containing every LuaRecipeCategoryPrototype indexed by |
||
font_prototypes [R] | :: LuaCustomTable[string → LuaFontPrototype] |
A dictionary containing every LuaFontPrototype indexed by |
A dictionary containing every LuaFontPrototype indexed by |
||
map_gen_presets [R] | :: LuaCustomTable[string → MapGenPreset] |
A dictionary containing every MapGenPreset indexed by |
A dictionary containing every MapGenPreset indexed by |
||
console_command_used [R] | :: boolean |
Whether a console command has been used. |
Whether a console command has been used. |
||
styles [R] | :: LuaCustomTable[string → string] |
The styles that LuaGuiElement can use, indexed by |
The styles that LuaGuiElement can use, indexed by |
||
tick [R] | :: uint |
Current map tick. |
Current map tick. |
||
ticks_played [R] | :: uint |
The number of ticks since this game was 'created'. |
The number of ticks since this game was 'created'. |
||
tick_paused [RW] | :: boolean |
If the tick has been paused. |
If the tick has been paused. |
||
ticks_to_run [RW] | :: uint |
The number of ticks to be run while the tick is paused. |
The number of ticks to be run while the tick is paused. |
||
finished [R] | :: boolean |
True while the victory screen is shown. |
True while the victory screen is shown. |
||
finished_but_continuing [R] | :: boolean |
True after players finished the game and clicked "continue". |
True after players finished the game and clicked "continue". |
||
speed [RW] | :: float |
Speed to update the map at. |
Speed to update the map at. |
||
surfaces [R] | :: LuaCustomTable[uint or string → LuaSurface] |
Get a table of all the surfaces that currently exist. |
Get a table of all the surfaces that currently exist. |
||
active_mods [R] | :: dictionary[string → string] |
The active mods versions. |
The active mods versions. |
||
connected_players [R] | :: array[LuaPlayer] |
The players that are currently online. |
The players that are currently online. |
||
permissions [R] | :: LuaPermissionGroups |
|
backer_names [R] | :: LuaCustomTable[uint → string] |
Array of the names of all the backers that supported the game development early on. |
Array of the names of all the backers that supported the game development early on. |
||
default_map_gen_settings [R] | :: MapGenSettings |
The default map gen settings for this save. |
The default map gen settings for this save. |
||
enemy_has_vision_on_land_mines [RW] | :: boolean |
Determines if enemy land mines are completely invisible or not. |
Determines if enemy land mines are completely invisible or not. |
||
autosave_enabled [RW] | :: boolean |
True by default. |
True by default. |
||
draw_resource_selection [RW] | :: boolean |
True by default. |
True by default. |
||
pollution_statistics [R] | :: LuaFlowStatistics |
The pollution statistics for this map. |
The pollution statistics for this map. |
||
max_force_distraction_distance [R] | :: double |
|
max_force_distraction_chunk_distance [R] | :: uint |
|
max_electric_pole_supply_area_distance [R] | :: float |
|
max_electric_pole_connection_distance [R] | :: double |
|
max_beacon_supply_area_distance [R] | :: double |
|
max_gate_activation_distance [R] | :: double |
|
max_inserter_reach_distance [R] | :: double |
|
max_pipe_to_ground_distance [R] | :: uint8 |
|
max_underground_belt_distance [R] | :: uint8 |
|
Set scenario state. Any parameters not provided do not change the current state.
game_finished | :: boolean? |
|
player_won | :: boolean? |
|
next_level | :: string? |
|
can_continue | :: boolean? |
|
victorious_force | :: ForceIdentification? |
|
Show an in-game message dialog.
text | :: LocalisedString |
What the dialog should say |
What the dialog should say |
||
image | :: string? |
Path to an image to show on the dialog |
Path to an image to show on the dialog |
||
point_to | :: GuiArrowSpecification? |
If specified, dialog will show an arrow pointing to this place. When not specified, the arrow will point to the player's position. (Use |
If specified, dialog will show an arrow pointing to this place. When not specified, the arrow will point to the player's position. (Use |
||
style | :: string? |
The gui style to use for this speech bubble. Must be of type speech_bubble. |
The gui style to use for this speech bubble. Must be of type speech_bubble. |
||
wrapper_frame_style | :: string? |
Must be of type flow_style. |
Must be of type flow_style. |
Can only be used when the map contains exactly one player.
Is this the demo version of Factorio?
Forces a reload of the scenario script from the original scenario location.
This disables the replay if replay is enabled.
Forces a reload of all mods.
This will act like saving and loading from the mod(s) perspective.
This will do nothing if run in multiplayer.
This disables the replay if replay is enabled.
Saves the current configuration of Atlas to a file. This will result in huge file containing all of the game graphics moved to as small space as possible.
Exists mainly for debugging reasons.
Run internal consistency checks. Allegedly prints any errors it finds.
Exists mainly for debugging reasons.
Regenerate autoplacement of some entities on all surfaces. This can be used to autoplace newly-added entities.
entities | :: string or array[string] |
Prototype names of entity or entities to autoplace. |
Prototype names of entity or entities to autoplace. |
All specified entity prototypes must be autoplacable.
Take a screenshot of the game and save it to the script-output
folder, located in the game's user data directory. The name of the image file can be specified via the path
parameter.
player | :: PlayerIdentification? |
The player to focus on. Defaults to the local player. |
The player to focus on. Defaults to the local player. |
||
by_player | :: PlayerIdentification? |
If defined, the screenshot will only be taken for this player. |
If defined, the screenshot will only be taken for this player. |
||
surface | :: SurfaceIdentification? |
If defined, the screenshot will be taken on this surface. |
If defined, the screenshot will be taken on this surface. |
||
position | :: MapPosition? |
If defined, the screenshot will be centered on this position. Otherwise, the screenshot will center on |
If defined, the screenshot will be centered on this position. Otherwise, the screenshot will center on |
||
resolution | :: TilePosition? |
The maximum allowed resolution is 16384x16384 (8192x8192 when |
The maximum allowed resolution is 16384x16384 (8192x8192 when |
||
zoom | :: double? |
The map zoom to take the screenshot at. Defaults to |
The map zoom to take the screenshot at. Defaults to |
||
path | :: string? |
The name of the image file. It should include a file extension indicating the desired format. Supports |
The name of the image file. It should include a file extension indicating the desired format. Supports |
||
show_gui | :: boolean? |
Whether to include GUIs in the screenshot or not. Defaults to |
Whether to include GUIs in the screenshot or not. Defaults to |
||
show_entity_info | :: boolean? |
Whether to include entity info ("Alt mode") or not. Defaults to |
Whether to include entity info ("Alt mode") or not. Defaults to |
||
show_cursor_building_preview | :: boolean? |
When |
When |
||
anti_alias | :: boolean? |
Whether to render in double resolution and downscale the result (including GUI). Defaults to |
Whether to render in double resolution and downscale the result (including GUI). Defaults to |
||
quality | :: int? |
The |
The |
||
allow_in_replay | :: boolean? |
Whether to save the screenshot even during replay playback. Defaults to |
Whether to save the screenshot even during replay playback. Defaults to |
||
daytime | :: double? |
Overrides the current surface daytime for the duration of screenshot rendering. |
Overrides the current surface daytime for the duration of screenshot rendering. |
||
water_tick | :: uint? |
Overrides the tick of water animation, if animated water is enabled. |
Overrides the tick of water animation, if animated water is enabled. |
||
force_render | :: boolean? |
Screenshot requests are processed in between game update and render. The game may skip rendering (ie. drop frames) if the previous frame has not finished rendering or the game simulation starts to fall below 60 updates per second. If |
Screenshot requests are processed in between game update and render. The game may skip rendering (ie. drop frames) if the previous frame has not finished rendering or the game simulation starts to fall below 60 updates per second. If |
If Factorio is running headless, this function will do nothing.
Forces the screenshot saving system to wait until all queued screenshots have been written to disk.
Take a screenshot of the technology screen and save it to the script-output
folder, located in the game's user data directory. The name of the image file can be specified via the path
parameter.
force | :: ForceIdentification? |
The force whose technology to screenshot. If not given, the |
The force whose technology to screenshot. If not given, the |
||
path | :: string? |
The name of the image file. It should include a file extension indicating the desired format. Supports |
The name of the image file. It should include a file extension indicating the desired format. Supports |
||
by_player | :: PlayerIdentification? |
If given, the screenshot will only be taken for this player. |
If given, the screenshot will only be taken for this player. |
||
selected_technology | :: TechnologyIdentification? |
The technology to highlight. |
The technology to highlight. |
||
skip_disabled | :: boolean? |
If |
If |
||
quality | :: int? |
The |
The |
Write a file to the script-output
folder, located in the game's user data directory. The name and file extension of the file can be specified via the filename
parameter.
filename | :: string |
The name of the file. Providing a directory path (ex. |
The name of the file. Providing a directory path (ex. |
||
data | :: LocalisedString |
The content to write to the file. |
The content to write to the file. |
||
append | :: boolean? |
If |
If |
||
for_player | :: uint? |
If given, the file will only be written for this |
If given, the file will only be written for this |
Remove a file or directory in the script-output
folder, located in the game's user data directory. Can be used to remove files created by LuaGameScript::write_file.
path | :: string |
The path to the file or directory to remove, relative to |
The path to the file or directory to remove, relative to |
Remove players who are currently not connected from the map.
players | :: array[LuaPlayer or string]? |
List of players to remove. If not specified, remove all offline players. |
List of players to remove. If not specified, remove all offline players. |
on_pre_player_removed instantly |
|
on_player_removed instantly |
|
Force a CRC check. Tells all peers to calculate their current map CRC; these CRC are then compared against each other. If a mismatch is detected, the game is desynced and some peers are forced to reconnect.
Create a new force.
force | :: string |
Name of the new force |
Name of the new force |
→ LuaForce |
The force that was just created |
on_force_created instantly |
|
The game currently supports a maximum of 64 forces, including the three built-in forces. This means that a maximum of 61 new forces may be created.
Force names must be unique.
Marks two forces to be merged together. All players and entities in the source force will be reassigned to the target force. The source force will then be destroyed. Importantly, this does not merge technologies or bonuses, which are instead retained from the target force.
source | :: ForceIdentification |
The force to remove. |
The force to remove. |
||
destination | :: ForceIdentification |
The force to reassign all entities to. |
The force to reassign all entities to. |
on_forces_merging future_tick |
|
on_forces_merged future_tick |
|
The three built-in forces (player, enemy and neutral) can't be destroyed, meaning they can't be used as the source argument to this function.
The source force is not removed until the end of the current tick, or if called during the on_forces_merging or on_forces_merged event, the end of the next tick.
Create a new surface.
name | :: string |
Name of the new surface. |
Name of the new surface. |
||
settings | :: MapGenSettings? |
Map generation settings. |
Map generation settings. |
→ LuaSurface |
The surface that was just created. |
on_surface_created instantly |
|
The game currently supports a maximum of 4,294,967,295 surfaces, including the default surface.
Surface names must be unique.
Instruct the server to save the map.
name | :: string? |
Save name. If not specified, writes into the currently-running save. |
Save name. If not specified, writes into the currently-running save. |
Instruct the game to perform an auto-save.
name | :: string? |
The autosave name if any. Saves will be named _autosave-name when provided. |
The autosave name if any. Saves will be named _autosave-name when provided. |
Only the server will save in multiplayer. In single player a standard auto-save is triggered.
Deletes the given surface and all entities on it.
surface | :: string or LuaSurface |
The surface to be deleted. Currently the primary surface (1, 'nauvis') cannot be deleted. |
The surface to be deleted. Currently the primary surface (1, 'nauvis') cannot be deleted. |
on_pre_surface_deleted future_tick |
|
on_surface_deleted future_tick |
|
Disables replay saving for the current save file. Once done there's no way to re-enable replay saving for the save file without loading an old save.
Disables tutorial triggers, that unlock new tutorials and show notices about unlocked tutorials.
Converts the given direction into the string version of the direction.
direction | :: defines.direction |
|
Print text to the chat console all players.
message | :: LocalisedString |
|
color | :: Color? |
|
Messages that are identical to a message sent in the last 60 ticks are not printed again.
Creates a deterministic standalone random generator with the given seed or if a seed is not provided the initial map seed is used.
seed | :: uint? |
|
Make sure you actually want to use this over math.random(...) as this provides entirely different functionality over math.random(...).
Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect.
Also prints true/false if called from the console.
Play a sound for every player in the game.
path | :: SoundPath |
The sound to play. |
The sound to play. |
||
position | :: MapPosition? |
Where the sound should be played. If not given, it's played at the current position of each player. |
Where the sound should be played. If not given, it's played at the current position of each player. |
||
volume_modifier | :: double? |
The volume of the sound to play. Must be between 0 and 1 inclusive. |
The volume of the sound to play. Must be between 0 and 1 inclusive. |
||
override_sound_type | :: SoundType? |
The volume mixer to play the sound through. Defaults to the default mixer for the given sound type. |
The volume mixer to play the sound through. Defaults to the default mixer for the given sound type. |
Checks if the given SoundPath is valid.
sound_path | :: SoundPath |
Path to the sound. |
Path to the sound. |
Checks if the given SpritePath is valid and contains a loaded sprite. The existence of the image is not checked for paths of type file
.
sprite_path | :: SpritePath |
Path to the image. |
Path to the image. |
Kicks the given player from this multiplayer game. Does nothing if this is a single player game or if the player running this isn't an admin.
player | :: PlayerIdentification |
The player to kick. |
The player to kick. |
||
reason | :: LocalisedString? |
The reason given if any. |
The reason given if any. |
on_player_kicked instantly |
|
on_console_command instantly |
|
Bans the given player from this multiplayer game. Does nothing if this is a single player game of if the player running this isn't an admin.
player | :: PlayerIdentification |
The player to ban. |
The player to ban. |
||
reason | :: LocalisedString? |
The reason given if any. |
The reason given if any. |
on_player_banned instantly |
|
on_console_command instantly |
|
Unbans the given player from this multiplayer game. Does nothing if this is a single player game of if the player running this isn't an admin.
player | :: PlayerIdentification |
The player to unban. |
The player to unban. |
on_player_unbanned instantly |
|
on_console_command instantly |
|
Purges the given players messages from the game. Does nothing if the player running this isn't an admin.
player | :: PlayerIdentification |
The player to purge. |
The player to purge. |
on_console_command instantly |
|
Mutes the given player. Does nothing if the player running this isn't an admin.
player | :: PlayerIdentification |
The player to mute. |
The player to mute. |
on_player_muted instantly |
|
on_console_command instantly |
|
Unmutes the given player. Does nothing if the player running this isn't an admin.
player | :: PlayerIdentification |
The player to unmute. |
The player to unmute. |
on_player_unmuted instantly |
|
on_console_command instantly |
|
Is the map loaded is multiplayer?
Gets the number of entities that are active (updated each tick).
surface | :: SurfaceIdentification? |
If given, only the entities active on this surface are counted. |
If given, only the entities active on this surface are counted. |
This is very expensive to determine.
Gets the map exchange string for the map generation settings that were used to create this map.
Convert a map exchange string to map gen settings and map settings.
map_exchange_string | :: string |
|
Gets train stops matching the given filters.
name | :: string or array[string]? |
The name(s) of the train stops. Not providing names will match any stop. |
The name(s) of the train stops. Not providing names will match any stop. |
||
surface | :: SurfaceIdentification? |
The surface to search. Not providing a surface will match stops on any surface. |
The surface to search. Not providing a surface will match stops on any surface. |
||
force | :: ForceIdentification? |
The force to search. Not providing a force will match stops in any force. |
The force to search. Not providing a force will match stops in any force. |
Creates a LuaProfiler, which is used for measuring script performance.
stopped | :: boolean? |
Create the timer stopped |
Create the timer stopped |
LuaProfiler cannot be serialized.
Evaluate an expression, substituting variables as provided. For details on the formula, see the relevant page on the Factorio wiki.
expression | :: string |
The expression to evaluate. |
The expression to evaluate. |
||
variables | :: dictionary[string → double]? |
Variables to be substituted. |
Variables to be substituted. |
Calculate the number of research units required to unlock mining productivity level 10.
|
Returns a dictionary of all LuaEntityPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[EntityPrototypeFilter] |
|
Get every entity prototype that can craft recipes involving fluids in the way some assembling machines can.
|
Returns a dictionary of all LuaItemPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[ItemPrototypeFilter] |
|
Get every item prototype that, when launched with a rocket, produces a result.
|
Returns a dictionary of all LuaEquipmentPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[EquipmentPrototypeFilter] |
|
Get every equipment prototype that functions as a battery.
|
Returns a dictionary of all LuaModSettingPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[ModSettingPrototypeFilter] |
|
Get every mod setting prototype that belongs to the specified mod.
|
Returns a dictionary of all LuaAchievementPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[AchievementPrototypeFilter] |
|
Get every achievement prototype that is not allowed to be completed on the peaceful difficulty setting.
|
Returns a dictionary of all LuaTilePrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[TilePrototypeFilter] |
|
Get every tile prototype that improves a player's walking speed by at least 50%.
|
Returns a dictionary of all LuaDecorativePrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[DecorativePrototypeFilter] |
|
Get every decorative prototype that is auto-placed.
|
Returns a dictionary of all LuaFluidPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[FluidPrototypeFilter] |
|
Get every fluid prototype that has a heat capacity of exactly
|
Returns a dictionary of all LuaRecipePrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[RecipePrototypeFilter] |
|
Get every recipe prototype that takes less than half a second to craft (at crafting speed
|
Returns a dictionary of all LuaTechnologyPrototypes that fit the given filters. The prototypes are indexed by name
.
filters | :: array[TechnologyPrototypeFilter] |
|
Get every technology prototype that can be researched at the start of the game.
|
Creates an inventory that is not owned by any game object. It can be resized later with LuaInventory::resize.
size | :: uint16 |
The number of slots the inventory initially has. |
The number of slots the inventory initially has. |
Make sure to destroy it when you are done with it using LuaInventory::destroy.
Gets the inventories created through LuaGameScript::create_inventory
mod | :: string? |
The mod who's inventories to get. If not provided all inventories are returned. |
The mod who's inventories to get. If not provided all inventories are returned. |
→ dictionary[string → array[LuaInventory]] |
A mapping of mod name to array of inventories owned by that mod. |
Inventories created through console commands will be owned by "core"
.
This object's name.
This property is only populated inside custom command handlers and when writing Lua console commands. Returns the player that is typing the command, nil
in all other instances.
See LuaGameScript::players for accessing all players.
Get a table of all the players that currently exist. This sparse table allows you to find players by indexing it with either their name
or index
. Iterating this table with pairs()
will only iterate the array part of the table. Iterating with ipairs()
will not work at all.
If only a single player is required, LuaGameScript::get_player should be used instead, as it avoids the unnecessary overhead of passing the whole table to Lua.
The currently active set of map settings. Even though this property is marked as read-only, the members of the dictionary that is returned can be modified mid-game.
This does not contain difficulty settings, use LuaGameScript::difficulty_settings instead.
The currently active set of difficulty settings. Even though this property is marked as read-only, the members of the dictionary that is returned can be modified mid-game. This is however not recommended as different difficulties can have differing technology and recipe trees, which can cause problems for players.
This will set the technology price multiplier to 12.
|
Current scenario difficulty.
Get a table of all the forces that currently exist. This sparse table allows you to find forces by indexing it with either their name
or index
. Iterating this table with pairs()
will only iterate the array part of the table. Iterating with ipairs()
will not work at all.
A dictionary containing every LuaEntityPrototype indexed by name
.
A dictionary containing every LuaItemPrototype indexed by name
.
A dictionary containing every LuaFluidPrototype indexed by name
.
A dictionary containing every LuaTilePrototype indexed by name
.
A dictionary containing every LuaEquipmentPrototype indexed by name
.
A dictionary containing every LuaDamagePrototype indexed by name
.
A dictionary containing every LuaVirtualSignalPrototype indexed by name
.
A dictionary containing every LuaEquipmentGridPrototype indexed by name
.
A dictionary containing every LuaRecipePrototype indexed by name
.
A dictionary containing every LuaTechnologyPrototype indexed by name
.
A dictionary containing every LuaDecorativePrototype indexed by name
.
A dictionary containing every LuaParticlePrototype indexed by name
.
A dictionary containing every LuaAutoplaceControlPrototype indexed by name
.
A dictionary containing every LuaNoiseLayerPrototype indexed by name
.
A dictionary containing every LuaModSettingPrototype indexed by name
.
A dictionary containing every LuaCustomInputPrototype indexed by name
.
A dictionary containing every LuaAmmoCategoryPrototype indexed by name
.
A dictionary containing every LuaNamedNoiseExpression indexed by name
.
A dictionary containing every ItemSubgroup indexed by name
.
A dictionary containing every ItemGroup indexed by name
.
A dictionary containing every LuaFuelCategoryPrototype indexed by name
.
A dictionary containing every LuaResourceCategoryPrototype indexed by name
.
A dictionary containing every LuaAchievementPrototype indexed by name
.
A dictionary containing every LuaModuleCategoryPrototype indexed by name
.
A dictionary containing every LuaEquipmentCategoryPrototype indexed by name
.
A dictionary containing every LuaTrivialSmokePrototype indexed by name
.
A dictionary containing every LuaShortcutPrototype indexed by name
.
A dictionary containing every LuaRecipeCategoryPrototype indexed by name
.
A dictionary containing every LuaFontPrototype indexed by name
.
A dictionary containing every MapGenPreset indexed by name
.
A MapGenPreset is an exact copy of the prototype table provided from the data stage.
Whether a console command has been used.
The styles that LuaGuiElement can use, indexed by name
.
Current map tick.
The number of ticks since this game was 'created'. A game is 'created' either by using "new game" or "new game from scenario".
This differs over LuaGameScript::tick in that making a game from a scenario always starts with ticks_played value at 0 even if the scenario has its own level data where the LuaGameScript::tick is > 0.
This value has no relation with LuaGameScript::tick and can be completely different values.
If the tick has been paused. This means that entity update has been paused.
The number of ticks to be run while the tick is paused. When LuaGameScript::tick_paused is true, ticks_to_run behaves the following way: While this is > 0, the entity update is running normally and this value is decremented every tick. When this reaches 0, the game will pause again.
True while the victory screen is shown.
True after players finished the game and clicked "continue".
Speed to update the map at. 1.0 is normal speed -- 60 UPS.
Minimum value is 0.01.
Get a table of all the surfaces that currently exist. This sparse table allows you to find surfaces by indexing it with either their name
or index
. Iterating this table with pairs()
will only iterate the array part of the table. Iterating with ipairs()
will not work at all.
The active mods versions. The keys are mod names, the values are the versions.
This will print the names and versions of active mods to player p's console.
|
The players that are currently online.
This is primarily useful when you want to do some action against all online players.
This does not index using player index. See LuaPlayer::index on each player instance for the player index.
Array of the names of all the backers that supported the game development early on. These are used as names for labs, locomotives, radars, roboports, and train stops.
The default map gen settings for this save.
Determines if enemy land mines are completely invisible or not.
True by default. Can be used to disable autosaving. Make sure to turn it back on soon after.
True by default. Can be used to disable the highlighting of resource patches when they are hovered on the map.
The pollution statistics for this map.