help() | Internal |
set_game_state{game_finished=…, player_won=…, next_level=…, can_continue=…} | Set scenario state. |
get_entity_by_tag(tag) → LuaEntity | |
show_message_dialog{text=…, image=…, point_to=…} | Show an in-game message dialog. |
disable_tips_and_tricks() | Disable showing tips and tricks. |
is_demo() → boolean | Is this the demo version of Factorio? |
reload_script() | Forces a reload of the scenario script when the save game without the migration is loaded. |
save_atlas() | Saves the current configuration of Atlas to a file. |
check_consistency() | Run internal consistency checks. |
regenerate_entity(entities) | Regenerate autoplacement of some entities on all surfaces. |
take_screenshot{player=…, by_player=…, surface=…, position=…, resolution=…, zoom=…, path=…, show_gui=…, show_entity_info=…, anti_alias=…} | Take a screenshot and save it to a file. |
write_file(filename, data, append, for_player) | Write a string to a file. |
remove_path(path) | Remove file or directory. |
remove_offline_players(players) | Remove players who are currently not connected from the map. |
force_crc() | Force a CRC check. |
create_force(force) → LuaForce | Create a new force. |
merge_forces(source, destination) | Merge two forces together. |
create_surface(name, settings) → LuaSurface | Create a new surface |
server_save(name) | Instruct the server to save the map. |
delete_surface(surface) | Deletes the given surface and all entities on it. |
disable_replay() | Disables replay saving for the current save file. |
direction_to_string(direction) | Converts the given direction into the string version of the direction. |
print(message, color) | 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. |
check_prototype_translations() | Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect. |
play_sound{path=…, position=…, volume_modifier=…} → boolean | Plays a sound for every player in the game on every surface. |
is_valid_sound_path(SoundPath) → boolean | Checks if the given sound path is valid. |
kick_player(PlayerSpecification, reason) | Kicks the given player from this multiplayer game. |
ban_player(PlayerSpecification, reason) | Bans the given player from this multiplayer game. |
unban_player(PlayerSpecification) | Unbans the given player from this multiplayer game. |
purge_player(PlayerSpecification) | Purges the given players messages from the game. |
mute_player(PlayerSpecification) | Mutes the given player. |
unmute_player(PlayerSpecification) | Unmutes the given player. |
count_pipe_groups() | Counts how many distinct groups of pipes exist in the world. |
player :: LuaPlayer [R] | The player typing at the console - nil in all other instances. |
players :: custom dictionary uint or string → LuaPlayer [R] | |
map_settings :: MapSettings [R] | |
difficulty_settings :: DifficultySettings [R] | Although it can be done; because different difficulties can have different technology or recipe trees it's not recommended to change difficulty settings mid-game. |
difficulty :: defines.difficulty [R] | Current scenario difficulty. |
forces :: custom dictionary string → LuaForce [R] | |
entity_prototypes :: custom dictionary string → LuaEntityPrototype [R] | |
item_prototypes :: custom dictionary string → LuaItemPrototype [R] | |
fluid_prototypes :: custom dictionary string → LuaFluidPrototype [R] | |
tile_prototypes :: custom dictionary string → LuaTilePrototype [R] | |
equipment_prototypes :: custom dictionary string → LuaEquipmentPrototype [R] | |
damage_prototypes :: custom dictionary string → LuaDamagePrototype [R] | |
virtual_signal_prototypes :: custom dictionary string → LuaVirtualSignalPrototype [R] | |
equipment_grid_prototypes :: custom dictionary string → LuaEquipmentGridPrototype [R] | |
recipe_prototypes :: custom dictionary string → LuaRecipePrototype [R] | |
technology_prototypes :: custom dictionary string → LuaTechnologyPrototype [R] | |
decorative_prototypes :: custom dictionary string → LuaDecorativePrototype [R] | |
autoplace_control_prototypes :: custom dictionary string → LuaAutoplaceControlPrototype [R] | |
noise_layer_prototypes :: custom dictionary string → LuaNoiseLayerPrototype [R] | |
mod_setting_prototypes :: custom dictionary string → LuaModSettingPrototype [R] | |
custom_input_prototypes :: custom dictionary string → LuaCustomInputPrototype [R] | |
ammo_category_prototypes :: custom dictionary string → LuaAmmoCategoryPrototype [R] | |
tick :: uint [R] | Current map tick. |
finished :: boolean [R] | Is the scenario finished? |
speed :: float [RW] | Speed to update the map at. |
surfaces :: custom dictionary uint or string → LuaSurface [R] | |
active_mods :: dictionary string → string [R] | The active mods versions. |
connected_players :: array of LuaPlayer [R] | The online players This is primarily useful when you want to do some action against all online players. |
permissions :: LuaPermissionGroups [R] | |
backer_names :: custom dictionary uint → string [R] | |
default_map_gen_settings :: MapGenSettings [R] | The default map gen settings for this save. |
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
.
Internal
Show an in-game message dialog.
point_to={type="nowhere"}
to remove the arrow entirely.) The dialog itself will be placed near the arrow's target.Disable showing tips and tricks.
Is this the demo version of Factorio?
Forces a reload of the scenario script when the save game without the migration is loaded.
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.
Run internal consistency checks. Allegedly prints any errors it finds.
Take a screenshot and save it to a file.
Write a string to a file.
true
, this will append to the end of the file. Defaults to false
,Remove file or directory. Given path is taken relative to the script output directory. Can be used to remove files created by LuaGameScript::write_file.
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.
Merge two forces together. All entities in the source force will be reassigned to the target force. The source force will then be destroyed.
Create a new surface
Instruct the server to save the map.
Deletes the given surface and all entities on it.
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.
Converts the given direction into the string version of the direction.
Creates a deterministic standalone random generator with the given seed or if a seed is not provided the initial map seed is used.
Goes over all items, entities, tiles, recipes, technologies among other things and logs if the locale is incorrect.
Plays a sound for every player in the game on every surface.
Checks if the given sound path is valid.
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.
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.
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.
Purges the given players messages from the game. Does nothing if the player running this isn't an admin.
Mutes the given player. Does nothing if the player running this isn't an admin.
Unmutes the given player. Does nothing if the player running this isn't an admin.
Counts how many distinct groups of pipes exist in the world.
The player typing at the console - nil
in all other instances. See LuaGameScript::players for accessing all players.
Although it can be done; because different difficulties can have different technology or recipe trees it's not recommended to change difficulty settings mid-game.
Current scenario difficulty.
Current map tick.
Is the scenario finished?
Speed to update the map at. 1.0 is normal speed -- 60 UPS.
The active mods versions. The keys are mod names, the values are the versions.
for name, version in pairs(game.active_mods) do
p.print(name .. " version " .. version)
end
The online players
This is primarily useful when you want to do some action against all online players.
The default map gen settings for this save.