In other languages: Deutsch 日本語 한국어 Русский 简体中文

Console: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Readded commands that are part of /cheat - one might not want to do all of /cheat at once, so lets keep the other commands.)
(25 intermediate revisions by 8 users not shown)
Line 21: Line 21:
When the console is open, you'll see a blinking cursor at the bottom of the screen; type your message or command and hit '''Return''' to send it (this will also close the console).
When the console is open, you'll see a blinking cursor at the bottom of the screen; type your message or command and hit '''Return''' to send it (this will also close the console).
Documentation about message and command prefixes can be found further down this page.
Documentation about message and command prefixes can be found further down this page.
The console supports [[rich text]] tags. These tags are useful for sharing blueprints, marking map locations in chat or adding icons to map markers and train stations. Ctrl+alt clicking the map or ground will automatically insert a gps tag and post it into the console. Shift clicking most things with the console open will insert a tag for that thing into chat.


When console is closed, only the most recent messages/commands will be displayed, but they will gradually fade away (opening the console will immediately re-display all recent messages).
When console is closed, only the most recent messages/commands will be displayed, but they will gradually fade away (opening the console will immediately re-display all recent messages).
Line 117: Line 119:
| /toggle-heavy-mode
| /toggle-heavy-mode
| /toggle-heavy-mode
| /toggle-heavy-mode
| Used to investigate desyncs. Will slow down the game and make multiplayer unplayable.
| Used to investigate [[Desynchronization#Using_heavy_mode_command|desyncs]]. Will slow down the game and make multiplayer unplayable.
| Yes
| Yes
|-
|-
Line 123: Line 125:
| /toggle-rockets-sent-gui
| /toggle-rockets-sent-gui
| Toggles if the rockets sent button is shown in the upper left corner of the screen.
| Toggles if the rockets sent button is shown in the upper left corner of the screen.
| No
|-
| /unlock-shortcut-bar
| /unlock-shortcut-bar
| Unlocks all shortcut bar items.
| No
| No
|-
|-
Line 145: Line 152:
| Console input that does not start with {{keybinding|/}} is shown as a chat message to your team.
| Console input that does not start with {{keybinding|/}} is shown as a chat message to your team.
| No
| No
|-
| /admin
| /admin
| Opens the player management GUI.
| Yes
|-
|-
| /admins
| /admins
Line 292: Line 304:
! Command
! Command
! Description
! Description
|-
| /cheat <all>
| Researches all technologies and enables cheat mode. Using the '''all''' option also gives the player some additional items.
|-
| /command <command>
| Executes a Lua command.
|-
|-
| /c <command>
| /c <command>
| Executes a Lua command.
| Executes a Lua command.
|-
|-
| /command <command>
| /editor
| Executes a Lua command.
| Toggles the map editor.
|-
|-
| /measured-command <command>
| /measured-command <command>
Line 345: Line 363:
game.player.force.set_saved_technology_progress(tech, 0)
game.player.force.set_saved_technology_progress(tech, 0)
end
end
</syntaxhighlight>
=== Cancel current research ===
Cancels the current research.
<syntaxhighlight lang="lua">
/c game.player.force.current_research = nil
</syntaxhighlight>
</syntaxhighlight>


Line 418: Line 430:
p_armor.put({name = "battery-mk2-equipment"})
p_armor.put({name = "battery-mk2-equipment"})
player.insert{name="construction-robot", count = 25}
player.insert{name="construction-robot", count = 25}
player.insert{name="blueprint", count = 3}
player.insert{name="deconstruction-planner", count = 1}
player.insert{name="steel-axe", count = 10}
</syntaxhighlight>
</syntaxhighlight>


Line 501: Line 510:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/c game.player.surface.pollute(game.player.position, 1000000)
/c game.player.surface.pollute(game.player.position, 1000000)
</syntaxhighlight>
=== Where speakers are, by who ===
<syntaxhighlight lang="lua">
/c speakers = game.player.surface.find_entities_filtered{force = "player", type="programmable-speaker"}
for key, speaker in pairs(speakers) do
    game.player.print(speaker.last_user.name .. " placed a speaker at X=" .. speaker.position.x .. ", Y=" .. speaker.position.y)
end
</syntaxhighlight>
</syntaxhighlight>


Line 541: Line 558:
end
end
end
end
end
</syntaxhighlight>
=== Remove resources around the player ===
Removes all resource patches from the ground in a 50 x 50 area around the player.
<syntaxhighlight lang="lua">
/c local surface=game.player.surface
local size=50
local pos=game.player.position
for _, e in pairs(surface.find_entities_filtered{area={{pos.x-size, pos.y-size},{pos.x+size, pos.y+size}}, type="resource"})
do e.destroy()
end
end
</syntaxhighlight>
</syntaxhighlight>
Line 562: Line 592:
game.player.surface.create_entity({name="crude-oil", amount=100000, position=position})
game.player.surface.create_entity({name="crude-oil", amount=100000, position=position})
end
end
end
</syntaxhighlight>
=== Create 10 fishes ===
This creates 10 fishes around of player. The player must be on the water edge.
<syntaxhighlight lang="lua">
/c local player = game.player
local surface = player.surface
for i = 1, 10 do
  local position = surface.find_non_colliding_position('fish', player.position, 10, 1)
  if not position then return end
  surface.create_entity {name = 'fish', position = position}
end
end
</syntaxhighlight>
</syntaxhighlight>
Line 748: Line 790:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
/c game.player.create_character()
/c game.player.create_character()
</syntaxhighlight>
=== Enable long reach ===
Enables long reach, which allows the player to build and interact with entities at a greater distance. The default reach is 10.
<syntaxhighlight lang="lua">
/c local reach = 10000
game.player.force.character_build_distance_bonus = reach
game.player.force.character_reach_distance_bonus = reach
</syntaxhighlight>
</syntaxhighlight>


== Research scripts ==
== Research scripts ==
=== Enable Research Queue ===
Enable the research queue for the players current team. Can be done after the game has started if it was forgotten during the map's setup.
<syntaxhighlight lang="lua">
/c game.player.force.research_queue_enabled = true
</syntaxhighlight>


=== Enable faster research ===
=== Enable faster research ===
Line 786: Line 842:


== Command line parameters ==
== Command line parameters ==
'''As of Game Version 0.15.13'''
'''As of Game Version 0.17.5'''


Command line parameters can be used to set settings in the command line before the game launches, this is useful mainly for advanced users or server hosts.
Command line parameters can be used to set settings in the command line before the game launches, this is useful mainly for advanced users or server hosts.


General options:
{|
  -h [ --help ]                      display help
|'''General options:'''
  --version                         show version information
|-
  -v [ --verbose ]                  enable verbose logging
| -h, --help
  -c [ --config ] PATH               config file to use
| display help
  --no-log-rotation                 don't rotate log file
|-
  --mod-directory PATH               Mod directory to use
| --version
  --check-unused-prototype-data     Print a warning for all prototype values that were not accessed
|show version information
|-
| -v, --verbose
|enable verbose logging
|-
| -c, --config PATH
|config file to use
|-
| --no-log-rotation
|don't rotate log file
|-
| --mod-directory PATH
|Mod directory to use
|-
| --check-unused-prototype-data
|Print a warning for all prototype values that were not accessed
|-
| --executable-path PATH
|Override autodetected __PATH__executable. Usually not needed except on very weird systems.
|}
 
{|
|'''Running options:'''
|-
| -s, --map2scenario arg
|map to scenario conversion
|-
| -m, --scenario2map arg
|scenario to map conversion
|-
| --apply-update arg
|immediately apply update package
|-
| --create FILE
|create a new map
|-
| --map-gen-settings FILE
|Map generation settings for use with --create, --start-server-load-scenario or --generate-map-preview. See data/map-gen-settings.example.json
|-
| --map-gen-seed SEED
|Map generation seed for use with --create, --start-server-load-scenario or --generate-map-preview. Will override seed specified in map gen settings
|-
| --map-settings FILE
|Map settings for use with --create or --start-server-load-scenario. See data/base/prototypes/map-settings.lua
|-
| --preset arg
|Name of the map generation preset to be used.
|-
| --enable-runtime-autoplace-modification
|Allows changing autoplace specifications runtime in non-multiplayer non-replay enabled games for debug purposes.
|-
| --generate-map-preview PNGFILE
|Generate preview images of the map
|-
| --generate-tile-properties-csv CSVFILE
|Generate tile properties into a CSV file; can be used with --generate-map-preview
|-
| --map-preview-size SCALE
|Size (in pixels) of map preview (default: 1024)
|-
| --map-preview-scale SCALE
|Scale (meters per pixel) of map preview (default: 1)
|-
| --map-preview-offset X,Y
|Offset of the center of the map, in meters (default: 0,0)
|-
| --noise-outputs TAG,TAG...
|Indicate which variables of noise program to output
|-
| --slope-shading SHADEAMOUNT
|Apply elevation shading to map preview
|-
| --slope-shade-property SHADEPROP
|Property to apply slope shading to (default: elevation)
|-
| --report-quantities PROTOTYPE,...
|When generating map preview, report approximate quantities of the named entity prototypes
|-
| --threads THREADCOUNT
|Number of threads to use when generating map previews
|-
| --disable-migration-window
|Disables the gui that is shown when opening a save with migrated content
|-
| --start-server FILE
|start a multiplayer server
|-
| --start-server-load-scenario [MOD/]NAME
|start a multiplayer server and load the specified scenario. The scenario is looked for inside the given mod. If no mod is given, it is looked for in the top-level scenarios directory.
|-
| --start-server-load-latest
|start a multiplayer server and load the latest available save
|-
| --until-tick TICK
|run a save until given map tick
|-
| --benchmark FILE
|load save and run benchmark
|-
| --benchmark-ticks N
|number of ticks for benchmarking. Default is 1000 (default: 1000)
|-
| --benchmark-verbose FILE
|comma seperated list of timings to ouput each tick. "all", "timestamp" as well as all other values seen in the debug view are allowed here. An empty string disabled verbose benchmarking. (default: )
|-
| --output-perf-stats FILE
|path of file to which performance statistics measurements should be saved. Special tags {api}, {hw}, {time} and {tag} will be replaced.
|-
| --mp-connect ADDRESS
|start factorio and connect to address
|-
| --load-game FILE
|start Factorio and load a game in singleplayer
|-
| --benchmark-graphics FILE
|load save and run it with graphics for benchmark-ticks number of ticks as normal game would
|-
| --benchmark-frame FILE
|load save and benchmark graphics rendering of single frame (prepare + render) without updating the game
|-
| --force-opengl
|use OpenGL for rendering
|-
| --force-d3d
|use Direct3D for rendering
|-
| --debug-graphics
|enables debugging layer for graphics API. If DirectX is used DirectX SDK needs to be installed for this to work.
|-
| --fullscreen
|start game in windowed mode (saved to configuration)
|-
| --max-texture-size N
|maximal size of texture that the game can use (saved to configuration). Should be power of two greater than 2048
|-
| --graphics-quality arg
|accepted values: normal, low, very-low
|-
| --video-memory-usage arg
|accepted values: all, high, medium, low
|-
| --force-graphics-preset arg
|accepted values: very-low, low, mac-with-low-ram, medium-with-low-vram, medium, high, very-high, extreme
|-
| --gfx-safe-mode
|resets some graphics settings to values that should work on most configurations
|-
| --low-vram
|sprites that are not put into sprite atlases won't be allocated as texture objects
|-
| --shader arg
|enable/disable shader postprocessing (saved to configuration)
|-
| --disable-audio
|Disable audio. Mainly for faster startup during development.
|-
| --window-size arg
|Desired window resolution. For example "1680x1050". Or "maximized"
|-
| --single-thread-loading
|Disables loading of sprites in multiple threads.
|}


Running options:
{|
  -s [ --map2scenario ] arg          map to scenario conversion
|'''Server options:'''
  -m [ --scenario2map ] arg          scenario to map conversion
|-
  --apply-update arg                immediately apply update package
| --port N
  --create FILE                      create a new map
|network port to use
  --map-gen-settings FILE           Map generation settings for use with --create. See data/map-gen-settings.example.json
|-
  --map-settings FILE                Map settings for use with --create. See data/base/prototypes/map-settings.lua
| --bind ADDRESS[:PORT]
  --preset arg                      Name of the map generation preset to be used.
|IP address (and optionally port) to bind to
  --generate-map-preview FILE       Generate preview images of the map
|-
  --map-preview-size SCALE (=1,024)  Size (in pixels) of map preview
| --rcon-port N
  --map-preview-scale SCALE (=1)    Scale (meters per pixel) of map preview
|Port to use for RCON
  --map-preview-offset X,Y (=0,0)    Offset of the center of the map, in meters
|-
  --start-server FILE                start a multiplayer server
| --rcon-password PASSWORD
  --start-server-load-scenario FILE start a multiplayer server and load the specified scenario
|Password for RCON
  --start-server-load-latest        start a multiplayer server and load the latest available save
|-
  --until-tick TICK                  run a save until given map tick
| --server-settings FILE
  --mp-connect ADDRESS              start factorio and connect to address
|Path to file with server settings. See data/server-settings.example.json
  --load-game FILE                   start Factorio and load a game in singleplayer
|-
  --benchmark FILE                  load save and run benchmark
| --use-server-whitelist
  --benchmark-ticks N (=1,000)      number of ticks for benchmarking. Default is 1000
|If the whitelist should be used.
  --force-opengl                    use OpenGL for rendering
|-
  --force-d3d                        use Direct3D for rendering
| --server-whitelist FILE
  --fullscreen BOOL                  start game in windowed mode (saved to configuration)
|Path to file with server whitelist.
  --max-texture-size N              maximal size of texture that the game can use (saved to configuration). Should be power of two greater than 2048
|-
  --graphics-quality arg            accepted values: normal, low, very-low
| --server-banlist FILE
  --video-memory-usage arg          accepted values: all, high, medium, low
|Path to file with server banlist.
  --gfx-safe-mode                    resets some graphics settings to values that should work on most configurations
|-
  --shader arg                      enable/disable shader postprocessing (saved to configuration)
| --server-adminlist FILE
  --disable-audio                    Disable audio. Mainly for faster startup during development.
|Path to file with server adminlist.
|-
| --console-log FILE
|Path to file where a copy of the server's log will be stored
|-
| --server-id FILE
|Path where server ID will be stored or read from
|}


Server options:
  --port N                          network port to use
  --bind ADDRESS[:PORT]              IP address (and optionally port) to bind to
  --rcon-port N                      Port to use for RCON
  --rcon-password PASSWORD          Password for RCON
  --server-settings FILE            Path to file with server settings. See data/server-settings.example.json
  --server-whitelist FILE            Path to file with server whitelist.
  --server-banlist FILE              Path to file with server banlist.
  --console-log FILE                Path to file where a copy of the server's log will be stored
  --server-id FILE                  Path where server ID will be stored or read from


=== Multiplayer ===
=== Multiplayer ===

Revision as of 12:21, 20 March 2019

Overview

The Console is Factorio's command-line interface.

The in-game console is used for:

  • Chatting with other players
  • Running commands / scripts / cheats
  • Occasional status updates

There are three types of commands:

  • Normal - Display information about the game and customize your experience.
  • Multiplayer - Message filtering, banning users, etc.
  • Scripting/Cheating - Run small Lua scripts (but they disable achievements for the save game)

Using the console

The console display can be toggled with the / (slash) or ~ (tilde) keys.

You can customize the keys via Options Menu → Keyboard → Toggle Lua console. When the console is open, you'll see a blinking cursor at the bottom of the screen; type your message or command and hit Return to send it (this will also close the console). Documentation about message and command prefixes can be found further down this page.

The console supports rich text tags. These tags are useful for sharing blueprints, marking map locations in chat or adding icons to map markers and train stations. Ctrl+alt clicking the map or ground will automatically insert a gps tag and post it into the console. Shift clicking most things with the console open will insert a tag for that thing into chat.

When console is closed, only the most recent messages/commands will be displayed, but they will gradually fade away (opening the console will immediately re-display all recent messages). Note that by default, all executed commands are made visible to all users. You can set the fade out time via Options Menu → Other Settings → Message Delay.

If you want to immediately hide the console, open the console and then press Escape key (or press Return without entering any message/command). This not only closes the console, but it also hides all the recent messages/commands. The console can be cleared with the /clear command.

Note that the console can also accept raw Lua code as well as game commands.

Console history

The console has an inbuilt history; it's a bit like a text editor where only one line of text is displayed at a time.

Use the and keys to scroll through the console history.

Use the and keys to cursor through the currently displayed message or command, which you can edit (delete, insert, etc.) and resend (by pressing Return).

The Tab key will auto-complete commands and player ids.

Normal commands

Command Example Description Admin only
/alerts <enable/disable/mute/unmute> <alert> /alerts disable turret_fire Enables, disables, mutes, or unmutes the given alert type. Available alerts: entity_destroyed, entity_under_attack, not_enough_construction_robots, no_material_for_construction, not_enough_repair packs, turret_fire, custom, no_storage. No
/clear /clear Clears the console. No
/color <color> /color 20 255 255 100 Changes your color. Can either be one of the pre-defined colors or RGBA value in the format of “# # # #”. Available colors: default, red, green, blue, orange, yellow, pink, purple, white, black, gray, brown, cyan, acid. No
/evolution /evolution Prints info about the alien evolution factor. No
/help [command] /help Prints a list of available commands, the optional argument can specify the command that should be described. No
/h [command] /h Same as /help. No
/mute-programmable-speaker <mute/unmute> <local/everyone> /mute-programmable-speaker mute local Mutes or unmutes the global sounds created by the Programmable Speaker. Use “local” to mute just the local client. Admins can use “everyone” to mute the sounds for everyone on the server. No
/perf-avg-frames <number> /perf-avg-frames 100 Number of ticks/updates used to average performance counters. Default is 100. Value of 5-10 is recommended for fast convergence, but numbers will jitter more rapidly. No
/permissions /permissions Opens the permissions GUI. Yes
/screenshot [x resolution] [y resolution] [zoom] /screenshot Takes a screenshot with the GUI hidden, centered on the player. It is saved in the "script-output" subfolder of your User data directory. Resolution is optional and defaults to the current window size. Zoom is optional and defaults to 1. No
/seed /seed Prints the starting map seed. No
/time /time Prints info about how old the map is. No
/toggle-action-logging /toggle-action-logging Toggles logging all input actions performed by the game. This value isn’t persisted between game restarts and only affects your local game in multiplayer sessions. Yes
/toggle-heavy-mode /toggle-heavy-mode Used to investigate desyncs. Will slow down the game and make multiplayer unplayable. Yes
/toggle-rockets-sent-gui /toggle-rockets-sent-gui Toggles if the rockets sent button is shown in the upper left corner of the screen. No
/unlock-shortcut-bar /unlock-shortcut-bar Unlocks all shortcut bar items. No
/version /version Prints the current game version. No

Multiplayer commands

Command Example Description Admin only
<message> Hello team! Console input that does not start with / is shown as a chat message to your team. No
/admin /admin Opens the player management GUI. Yes
/admins /admins Prints a list of game admins. No
/ban <player> <reason> /ban xTROLLx Throwing grenades in base Bans the specified player. Yes
/banlist <add/remove/get/clear> <player> /banlist get Adds or removes a player from the banlist. Same as /ban or /unban. No
/config <get/set> <option> <value> /config set password hunter2 Gets or sets various multiplayer game settings. Available configs are: afk-auto-kick, allow-commands, allow-debug-settings, autosave-interval, autosave-only-on-server, ignore-player-limit-for-returning-players, max-players, max-upload-speed, only-admins-can-pause, password, require-user-verification, visibility-lan, visibility-public. Yes
/delete-blueprint-library <player> /delete-blueprint-library everybody confirm Deletes the blueprint library storage for the given offline player from the save file. Enter “everybody confirm” to delete the storage of all offline players. Yes
/demote <player> /demote AzureDiamond Demotes the player from admin. Yes
/ignore <player> /ignore Cthon98 Prevents the chat from showing messages from this player. Admin messages are still shown. No
/ignores /ignores Prints a list of ignored players. No
/kick <player> <reason> /kick xTROLLx Throwing grenades in base Kicks the specified player. Yes
/mute <player> /mute Cthon98 Prevents the player from saying anything in chat. Yes
/mutes /mutes All players that are muted (can’t talk in chat). No
/open <player> /open AzureDiamond Opens another player’s inventory. Yes
/o <player> /o AzureDiamond Same as /open. Yes
/players [online/o/count/c] /players Prints a list of players in the game. (parameter online/o, it prints only players that are online, count/c prints only count) No
/promote <player> /promote AzureDiamond Promotes the player to admin. Yes
/purge <player> /purge Cthon98 Clears all the messages from this player from the chat log. Yes
/reply <message> /reply oh, really? Replies to the last player that whispered to you. No
/r <message> /r oh, really? Same as /reply. No
/server-save /server-save Saves the game on the server in a multiplayer game. Yes
/shout <message> /shout Hello world! Sends a message to all players including other forces. No
/s <message> /s Hello world! Same as /shout. No
/swap-players <player> [player] /swap-players AzureDiamond Swaps your character with the given player’s character, or if two players are given swaps the two player characters. Yes
/unban <player> /unban xTROLLx Unbans the specified player. Yes
/unignore <player> /unignore Cthon98 Allows the chat to show messages from this player. No
/unmute <player> /unmute Cthon98 Allows the player to talk in chat again. Yes
/whisper <player> <message> /whisper AzureDiamond thats what I see Sends a message to the specified player. No
/w <player> <message> /w AzureDiamond thats what I see Same as /whisper. No
/whitelist <add/remove/get/clear> [player] /whitelist get Adds or removes a player from the whitelist, where only whitelisted players can join the game. Enter nothing for “player” when using “get” to print a list of all whitelisted players. An empty whitelist disables the whitelist functionality allowing anyone to join. No

Scripting and cheat commands

Command Description
/cheat <all> Researches all technologies and enables cheat mode. Using the all option also gives the player some additional items.
/command <command> Executes a Lua command.
/c <command> Executes a Lua command.
/editor Toggles the map editor.
/measured-command <command> Executes a Lua command and measures time it took.
/silent-command <command> Executes a Lua command without printing it to the console.

This is a very powerful feature, which also allows cheating, and as such achievements will be permanently disabled for the save as soon as you use a script command.

Basic example scripts

Use it as calculator

/c game.player.print(1234*5678)

Zoom beyond normal bounds

Note that zooming too far out can cause performance hits. Be careful.

/c game.player.zoom=0.1

Mine faster

/c game.player.force.manual_mining_speed_modifier=1000

Craft faster

/c game.player.force.manual_crafting_speed_modifier=1000

Unlock and research all technologies

/c game.player.force.research_all_technologies()

Undo this with the command in the next section.

Unresearch all technologies

This does not reset manually applied bonuses

/c for _, tech in pairs(game.player.force.technologies) do 
	tech.researched=false
	game.player.force.set_saved_technology_progress(tech, 0)
end

Reset your force

This resets all data for your force, including kill and production statistics, technologies, bonuses and charting status.

/c game.player.force.reset()

Always show rail block visualization

Permanently show the rail block visualization instead of only when holding a rail signal. Disable by replacing true with false.

/c game.player.game_view_settings.show_rail_block_visualisation = true

Inventory manipulation scripts

Cheat mode

Allows for infinite free crafting. Disable by replacing true with false.

/c game.player.cheat_mode=true

Refill resources (refill oil, iron etc.)

While holding the cursor over a resource tile in-game

/c game.player.selected.amount=7500

Alternatively you can refill all resources in the map with the following command. Change ore.amount to the desired value.

/c surface = game.player.surface
for _, ore in pairs(surface.find_entities_filtered({type="resource"})) do
    ore.amount = 10000
end

Add items to the player's inventory

Replace iron-plate with the internal name of the item desired.

/c game.player.insert{name="iron-plate", count=100}

For instance, here's a stack of the god-mode energy system interface:

/c game.player.insert{name="electric-energy-interface"}

Add a powerful armor with equipment and some tools for construction:

/c	local player = game.player
player.insert{name="power-armor-mk2", count = 1}
local p_armor = player.get_inventory(5)[1].grid
	p_armor.put({name = "fusion-reactor-equipment"})
	p_armor.put({name = "fusion-reactor-equipment"})
	p_armor.put({name = "fusion-reactor-equipment"})
	p_armor.put({name = "exoskeleton-equipment"})
	p_armor.put({name = "exoskeleton-equipment"})
	p_armor.put({name = "exoskeleton-equipment"})
	p_armor.put({name = "exoskeleton-equipment"})
	p_armor.put({name = "energy-shield-mk2-equipment"})
	p_armor.put({name = "energy-shield-mk2-equipment"})
	p_armor.put({name = "personal-roboport-mk2-equipment"})
	p_armor.put({name = "night-vision-equipment"})
	p_armor.put({name = "battery-mk2-equipment"})
	p_armor.put({name = "battery-mk2-equipment"})
player.insert{name="construction-robot", count = 25}

World manipulation scripts

Reveal the map around the player

Reveals the map around the player, similar to a radar.

/c local radius=150
game.player.force.chart(game.player.surface, {{game.player.position.x-radius, game.player.position.y-radius}, {game.player.position.x+radius, game.player.position.y+radius}})

or from start position

/c game.forces.player.chart(game.player.surface, {{x = -2000, y = -2000}, {x = 2000, y = 2000}})

Change 150 to the desired radius, higher values take longer.

Delete chunks

If much of the map is revealed, it increases the size of the save file. The following command cancels the generation of all chunks that are currently queued for generation and removes chunks outside a 32 chunks radius around 0,0. Note that this will remove player entities if there are any on these chunks.

/c local surface = game.player.surface;
game.player.force.cancel_charting(surface); 
local chunk_radius = 32;
for chunk in surface.get_chunks() do
  if (chunk.x < -chunk_radius or chunk.x > chunk_radius or chunk.y < -chunk_radius or chunk.y > chunk_radius) then
    surface.delete_chunk(chunk)
  end
end

Turn off night

Enables eternal day.

/c game.player.surface.always_day=true

Change game speed

0.5 is half speed, 1 is default, 2 is double speed, etc. Minimum is 0.01. This can be used for a lot of things like when you know you will have to wait for long periods of time for something to complete. Increasing will decrease performance, be careful.

/c game.speed=X

Expensive (marathon) or normal mode

To change from normal to expensive mode preset (this changes the research cost and intermediate product cost):

/c game.difficulty_settings.recipe_difficulty=1
game.difficulty_settings.technology_difficulty=1
game.difficulty_settings.technology_price_multiplier=4

To change back to normal:

/c game.difficulty_settings.recipe_difficulty=0
game.difficulty_settings.technology_difficulty=0
game.difficulty_settings.technology_price_multiplier=1

Freeze time

Stops the advancement of the time if you replace "BOOL" with "true" or unfreezes it if you replace it with "false".

/c game.player.surface.freeze_daytime=BOOL

Remove all pollution

/c game.player.surface.clear_pollution()

Completely turn off pollution

/c for _, surface in pairs(game.surfaces) do
  surface.clear_pollution()
end
game.map_settings.pollution.enabled = false

Add a lot of pollution

/c game.player.surface.pollute(game.player.position, 1000000)

Where speakers are, by who

/c speakers = game.player.surface.find_entities_filtered{force = "player", type="programmable-speaker"}
for key, speaker in pairs(speakers) do
    game.player.print(speaker.last_user.name .. " placed a speaker at X=" .. speaker.position.x .. ", Y=" .. speaker.position.y)
end

Disable friendly fire for your force

/c game.player.force.friendly_fire = false

Add new resource patch

This creates a new 11×11 patch of resources, centered on the player character, where the ground is not water. The patch it creates is perfectly square but it randomizes the amount similar to natural generation, with fewer ore at the edges and more ore in the center. The default numbers result in a patch with 2500-3000 ore.

If you want a larger patch, change "local size = 5" to a larger number. A larger patch will have exponentially more ore. Entering a number above 30 is not recommended.

If you want a richer patch, change "local density = 10" to a larger number. Entering a very large number shouldn't hurt anything but you probably don't need to go above 100.

To choose which resource is spawned, change "stone" near the bottom to "iron-ore", "copper-ore", "coal", or "uranium-ore".

/c local surface=game.player.surface
local ore=nil
local size=5
local density=10
for y=-size, size do
	for x=-size, size do
		a=(size+1-math.abs(x))*10
		b=(size+1-math.abs(y))*10
		if a<b then
			ore=math.random(a*density-a*(density-8), a*density+a*(density-8))
		end
		if b<a then
			ore=math.random(b*density-b*(density-8), b*density+b*(density-8))
		end
		if surface.get_tile(game.player.position.x+x, game.player.position.y+y).collides_with("ground-tile") then
			surface.create_entity({name="stone", amount=ore, position={game.player.position.x+x, game.player.position.y+y}})
		end
	end
end

Remove resources around the player

Removes all resource patches from the ground in a 50 x 50 area around the player.

/c local surface=game.player.surface
local size=50
local pos=game.player.position

for _, e in pairs(surface.find_entities_filtered{area={{pos.x-size, pos.y-size},{pos.x+size, pos.y+size}}, type="resource"}) 
	do e.destroy() 
end

Add new oil patch

This creates 9 crude oil patches in a 3×3 square.

/c for y=0,2 do
	for x=0,2 do
		game.player.surface.create_entity({name="crude-oil", amount=100000, position={game.player.position.x+x*7-7, game.player.position.y+y*7-7}})
	end
end

or randomly without any collision:

/c local position=nil
for i=1,9 do
	position=game.player.surface.find_non_colliding_position("crude-oil", game.player.position, 0, i/2+1.5)
	if position then 
		game.player.surface.create_entity({name="crude-oil", amount=100000, position=position})
	end
end

Create 10 fishes

This creates 10 fishes around of player. The player must be on the water edge.

/c local player = game.player
local surface = player.surface
for i = 1, 10 do
  local position = surface.find_non_colliding_position('fish', player.position, 10, 1)
  if not position then return end
  surface.create_entity {name = 'fish', position = position}
end

Count entities

Counts all entities whose name includes the string in local entity.

/c local entity="belt"
local surface=game.player.surface
local count=0
for key, ent in pairs(surface.find_entities_filtered({force=game.player.force})) do
	if string.find(ent.name,entity) then
		count=count+1
	end
end
game.player.print(count)

Emptying all pipes, underground pipes and pumps

Useful when pipes contain a fluid you dont want.

/c local surface = game.player.surface
local deleted=0
for key, entity in pairs(surface.find_entities_filtered({force=game.player.force})) do
	if string.find(entity.name, "pipe") or 
		string.find(entity.name, "pump") 
	then
		for i=1,#entity.fluidbox do
			deleted = deleted + 1
			entity.fluidbox[i] = nil;
		end
	end
end
game.player.print("Fluids removed from "..deleted .." entities")

Turn off cliff generation

Sets size to "none". Only effective on chunks that are generated after using this command. Use #Remove all cliffs to delete existing cliffs.

/c local mgs = game.player.surface.map_gen_settings
mgs.cliff_settings.cliff_elevation_0 = 1024
game.player.surface.map_gen_settings = mgs

Remove all cliffs

Removes all cliffs existing cliffs from the world. Use #Turn off cliff generation to turn off cliff generation in new chunks.

/c for _, v in pairs(game.player.surface.find_entities_filtered{type="cliff"}) do
  v.destroy()
end

Delete all decoratives

Delete the decoratives that can be found in the world.

/c local surface = game.player.surface
for c in surface.get_chunks() do
	surface.destroy_decoratives({{c.x*32, c.y*32}, {c.x*32+32, c.y*32+32}})
end

Change map generation settings

This allows to change the map generation settings for new chunks; it does not alter already generated chunks. Deleted chunks are affected by the setting change because they are newly generated when they get explored again.

To change resource generation settings, replace "iron-ore" with the resource that should be changed and replace "very-high" with the desired MapGenSize in the following command. Replace "iron-ore" with "enemy-base" to change the enemy base generation settings.

/c local surface = game.player.surface
local resource = "iron-ore"
local autoplace = surface.map_gen_settings.autoplace_controls
autoplace[resource].size = "very-high"
autoplace[resource].frequency = "very-high"
autoplace[resource].richness = "very-high"
surface.map_gen_settings.autoplace_controls = autoplace

To change water generation settings, replace "very-high" with the desired MapGenSize in the following command.

/c local surface = game.player.surface
local mgs = surface.map_gen_settings
mgs.water = "very-high" --[[ size]]
mgs.terrain_segmentation  = "very-high" --[[ frequency]]
surface.map_gen_settings = mgs

Enemy/evolution scripts

Set evolution factor

Ranges from 0 (new game) to 1.

/c game.forces["enemy"].evolution_factor=X

Disable time-based evolution & increases pollution-based evolution

/c game.map_settings.enemy_evolution.time_factor=0
/c game.map_settings.enemy_evolution.pollution_factor=game.map_settings.enemy_evolution.pollution_factor*2

The "2" at the end of the last command will double the default pollution factor. You can substitute another number to increase (or decrease) the pollution factor further.

Kill all biters on the "enemy" force

Note that this will kill only mobile units, spawners will not be killed.

/c game.forces["enemy"].kill_all_units()

Kill all enemies

This will kill all biters, bases and worms. Anything that is an enemy will be completely destroyed. This only affects enemies in the explored world, so any unexplored parts of the map which still need to be generated will still have enemies. You can prevent biters being on newly generated chunks if desired.

/c local surface=game.player.surface
for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do
	entity.destroy()
end

Kill all nearby enemies

This will kill all biters, bases and worms in a configurable radius. The default, 250 tiles, is about two zoomed-out screen widths on full HD. After destruction, it shows how many objects were destroyed.

/c local radius = 250
local surface=game.player.surface
local pp = game.player.position
local cnt = 0
for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do
    if entity.position.x > pp.x - radius and entity.position.x < pp.x + radius
        and entity.position.y > pp.y - radius and entity.position.y < pp.y + radius then
        cnt = cnt+1
        entity.destroy()
    end
end
game.player.print(cnt)

Enable/Disable peaceful mode

Enabling peaceful mode prevents biter attacks until provoked. Substitute true for false to disable. Already existing biters are not affected by this command so attacks could continue for a while after activating peaceful mode.

/c game.player.surface.peaceful_mode = true

Enable/Disable biter expansion

Biter expansion allows biters to create new nests, it is enabled by default. Substitute true for false to disable.

/c game.map_settings.enemy_expansion.enabled = true

Prevent biters being on newly generated chunks

On newly generated chunks no biters will be present, however all current biters will remain unaffected. Equivalent of setting the Enemy Base Size to None under the Terrain settings during map generation but achieved mid game by changing map generation settings.

/c local surface = game.player.surface
local mgs = surface.map_gen_settings
mgs.autoplace_controls["enemy-base"].size = "none"
surface.map_gen_settings = mgs

Player character scripts

Commands concerning the player directly.

Get player position

Prints coordinates of your current position.

/c game.player.print(game.player.position.x .. ", " .. game.player.position.y)

Teleport player

Moves the player to the specified location. You should be able to teleport to a specific player if you obtain their coordinates via them executing the previous command and giving them to you.

/c game.player.teleport({X, Y})

To teleport to the world's origin, use 0,0.

Enable god mode

God mode removes your player character allowing you to fly over obstacles and take no damage.

Disassociate your controls from the player:

/c game.player.character=nil

Then, hover the mouse over the useless player and destroy it by typing:

/c game.player.selected.destroy()

To undo, spawn a player character. This will spawn a new player at the spawn point of the world, and connect your controls to it.

/c game.player.create_character()

Enable long reach

Enables long reach, which allows the player to build and interact with entities at a greater distance. The default reach is 10.

/c local reach = 10000
game.player.force.character_build_distance_bonus = reach
game.player.force.character_reach_distance_bonus = reach

Research scripts

Enable Research Queue

Enable the research queue for the players current team. Can be done after the game has started if it was forgotten during the map's setup.

/c game.player.force.research_queue_enabled = true

Enable faster research

/c game.player.force.laboratory_speed_modifier=1

1 is normal speed, 2 is double speed 3 is triple etc.

Research specific technologies

The internal technology names can be found in the infoboxes on their respective pages.

/c game.player.force.technologies['electric-energy-distribution-1'].researched=true
/c game.player.force.technologies['steel-processing'].researched=true

Unresearch specific technologies

The internal technology names can be found in the infoboxes on their respective pages.

/c game.player.force.technologies['electric-energy-distribution-1'].researched=false; game.player.force.set_saved_technology_progress('electric-energy-distribution-1', 0)
/c game.player.force.technologies['steel-processing'].researched=false; game.player.force.set_saved_technology_progress('steel-processing', 0)

Enabling specific recipes

The internal recipe/item names can be found in the infoboxes on their respective pages.

/c game.player.force.recipes["electric-energy-interface"].enabled=true
/c game.player.force.recipes["rocket-silo"].enabled=true
/c game.player.force.recipes.loader.enabled=true

Enable all recipes

/c for name, recipe in pairs(game.player.force.recipes) do recipe.enabled = true end

Command line parameters

As of Game Version 0.17.5

Command line parameters can be used to set settings in the command line before the game launches, this is useful mainly for advanced users or server hosts.

General options:
-h, --help display help
--version show version information
-v, --verbose enable verbose logging
-c, --config PATH config file to use
--no-log-rotation don't rotate log file
--mod-directory PATH Mod directory to use
--check-unused-prototype-data Print a warning for all prototype values that were not accessed
--executable-path PATH Override autodetected __PATH__executable. Usually not needed except on very weird systems.
Running options:
-s, --map2scenario arg map to scenario conversion
-m, --scenario2map arg scenario to map conversion
--apply-update arg immediately apply update package
--create FILE create a new map
--map-gen-settings FILE Map generation settings for use with --create, --start-server-load-scenario or --generate-map-preview. See data/map-gen-settings.example.json
--map-gen-seed SEED Map generation seed for use with --create, --start-server-load-scenario or --generate-map-preview. Will override seed specified in map gen settings
--map-settings FILE Map settings for use with --create or --start-server-load-scenario. See data/base/prototypes/map-settings.lua
--preset arg Name of the map generation preset to be used.
--enable-runtime-autoplace-modification Allows changing autoplace specifications runtime in non-multiplayer non-replay enabled games for debug purposes.
--generate-map-preview PNGFILE Generate preview images of the map
--generate-tile-properties-csv CSVFILE Generate tile properties into a CSV file; can be used with --generate-map-preview
--map-preview-size SCALE Size (in pixels) of map preview (default: 1024)
--map-preview-scale SCALE Scale (meters per pixel) of map preview (default: 1)
--map-preview-offset X,Y Offset of the center of the map, in meters (default: 0,0)
--noise-outputs TAG,TAG... Indicate which variables of noise program to output
--slope-shading SHADEAMOUNT Apply elevation shading to map preview
--slope-shade-property SHADEPROP Property to apply slope shading to (default: elevation)
--report-quantities PROTOTYPE,... When generating map preview, report approximate quantities of the named entity prototypes
--threads THREADCOUNT Number of threads to use when generating map previews
--disable-migration-window Disables the gui that is shown when opening a save with migrated content
--start-server FILE start a multiplayer server
--start-server-load-scenario [MOD/]NAME start a multiplayer server and load the specified scenario. The scenario is looked for inside the given mod. If no mod is given, it is looked for in the top-level scenarios directory.
--start-server-load-latest start a multiplayer server and load the latest available save
--until-tick TICK run a save until given map tick
--benchmark FILE load save and run benchmark
--benchmark-ticks N number of ticks for benchmarking. Default is 1000 (default: 1000)
--benchmark-verbose FILE comma seperated list of timings to ouput each tick. "all", "timestamp" as well as all other values seen in the debug view are allowed here. An empty string disabled verbose benchmarking. (default: )
--output-perf-stats FILE path of file to which performance statistics measurements should be saved. Special tags {api}, {hw}, {time} and {tag} will be replaced.
--mp-connect ADDRESS start factorio and connect to address
--load-game FILE start Factorio and load a game in singleplayer
--benchmark-graphics FILE load save and run it with graphics for benchmark-ticks number of ticks as normal game would
--benchmark-frame FILE load save and benchmark graphics rendering of single frame (prepare + render) without updating the game
--force-opengl use OpenGL for rendering
--force-d3d use Direct3D for rendering
--debug-graphics enables debugging layer for graphics API. If DirectX is used DirectX SDK needs to be installed for this to work.
--fullscreen start game in windowed mode (saved to configuration)
--max-texture-size N maximal size of texture that the game can use (saved to configuration). Should be power of two greater than 2048
--graphics-quality arg accepted values: normal, low, very-low
--video-memory-usage arg accepted values: all, high, medium, low
--force-graphics-preset arg accepted values: very-low, low, mac-with-low-ram, medium-with-low-vram, medium, high, very-high, extreme
--gfx-safe-mode resets some graphics settings to values that should work on most configurations
--low-vram sprites that are not put into sprite atlases won't be allocated as texture objects
--shader arg enable/disable shader postprocessing (saved to configuration)
--disable-audio Disable audio. Mainly for faster startup during development.
--window-size arg Desired window resolution. For example "1680x1050". Or "maximized"
--single-thread-loading Disables loading of sprites in multiple threads.
Server options:
--port N network port to use
--bind ADDRESS[:PORT] IP address (and optionally port) to bind to
--rcon-port N Port to use for RCON
--rcon-password PASSWORD Password for RCON
--server-settings FILE Path to file with server settings. See data/server-settings.example.json
--use-server-whitelist If the whitelist should be used.
--server-whitelist FILE Path to file with server whitelist.
--server-banlist FILE Path to file with server banlist.
--server-adminlist FILE Path to file with server adminlist.
--console-log FILE Path to file where a copy of the server's log will be stored
--server-id FILE Path where server ID will be stored or read from


Multiplayer

 --start-server SAVE

Will start a Headless (Dedicated) server, with no GUI.

 --mp-connect ADDRESS

ADDRESS is the IP:port of the remote host. Port is optional. Examples:

 ./factorio --mp-connect 192.168.1.101
 ./factorio --mp-connect 192.168.1.101:2345

As above, port can be specified by placing the port number after a colon in the address.

 --map2scenario SAVE

Converts a save game to a User Scenario, allows saved game state to be loaded into map editor. Assuming that save game name is "foo.zip", executing './factorio --map2scenario s1' will result in Factorio loading, opening the save file, and saving the scenario into the scenario folder.

Modding tools

A list of the internal names of most things in the vanilla game can also be found on data.raw.

Print to console which tile are you have under the player position

/c game.player.print(game.player.surface.get_tile(game.player.position.x, game.player.position.y).name)

Write all researched technologies to file

/c local list = {}
for _, tech in pairs(game.player.force.technologies) do 
	if tech.researched then
    list[#list+1] = tech.name
  end
end
game.write_file("techs.lua", serpent.block(list) .. "\n", true)

Write all enabled recipes to file

/c local list = {}
for _, recipe in pairs(game.player.force.recipes) do 
	if recipe.enabled then
    list[#list+1] = recipe.name
  end
end
game.write_file("recipes.lua", serpent.block(list) .. "\n", true)

See also