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

Console: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
m (Updated the entry for "Write mod list to file" to work with modern changes.)
 
(201 intermediate revisions by 42 users not shown)
Line 1: Line 1:
{{Languages}}
{{Languages}}
The '''console''' is Factorio's in-game command-line interface. See [[command line parameters]] for the command line interface of the Factorio executable.


== Overview ==
The in-game console can be used for:
The in-game console is used for:


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


There are three types of command:
There are three types of commands:
 
* '''[[#Normal commands|Normal]]''' - Display information about the game and customize your experience.
* '''[[#Multiplayer commands|Multiplayer]]''' - Message filtering, banning users, etc.
* '''[[#Scripting and cheat commands|Scripting/Cheating]]''' - Run small Lua scripts (but they <span style="color:#FF0000">disable achievements for the save game</span>)


* '''Multiplayer''' - message filtering, banning users, etc.
__TOC__
* '''Information''' - display various information about the game
* '''Scripting/Cheating''' - run small Lua scripts (but they <span style="color:#FF0000">disable achievements for the save game</span>)


=== Using the console ===
=== Using the console ===
The console display can be toggled with the {{keybinding|/}} (slash) or {{keybinding|~}} (tilde) keys.
The console display can be toggled with the {{Keybinding|grave}} key (<code>`</code>). This is the key located to the left of the <code>1</code> key, above <code>Tab</code>.


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.
You can customize the keys via '''Settings menu → Controls → Toggle chat (and 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.


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'''.
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 the console.


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. In [https://forums.factorio.com/viewtopic.php?f=3&t=32389 Factorio 0.14.5 and later], you can clear the console with the '''/clear''' command.
When the 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. The fade-out time can be changed via '''Settings menu → Interface → Chat message delay'''.


Note that the console can also accept raw Lua code as well as game commands.
The console can be cleared with the '''/clear''' command.


=== Console history ===
Use the {{keybinding|&uarr;}} and {{keybinding|&darr;}} keys to scroll through the console history. The {{keybinding|Tab}} key provides intelligent code completion on commands, options and player names.


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.
== Normal commands ==


Use the {{keybinding|&uarr;}} and {{keybinding|&darr;}} keys to scroll through the console history.
{| class="wikitable"
|-
! style="width:25%"| Command
! style="width:25%"| Example
! style="width:46%"| Description
! style="width:4%"| Admin only
|-
| /alerts <enable/disable/mute/unmute> <alert>
| /alerts disable turret_fire
| Enables, disables, mutes, or unmutes the given  [[alerts|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, train_out_of_fuel, fluid_mixing.
| No
|-
| /clear
| /clear
| Clears the console.
| No
|-
| /color <color>
| /color 20 255 255
| Changes your color. Can either be one of the pre-defined colors or [[:Wikipedia:RGB_color_space|RGB 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
|-
| /permissions <action> <parameters>
| /permissions add-player DeveloperGroup kovarex
| Available actions are add-player <group> <player>, create-group <name>, delete-group <group>, edit-group <group> <input_action> <true/false>, get-player-group <player>, remove-player <group> <player>, rename-group <group> <new_name> and reset
| Yes
|-
| /reset-tips
| /reset-tips
| Resets the state of the tips and tricks as if the game was just started for the first time.
| No
|-
| /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 [[Desynchronization#Using_heavy_mode_command|desyncs]]. Will slow down the game and make multiplayer unplayable.
| Yes
|-
| /unlock-shortcut-bar
| /unlock-shortcut-bar
| Unlocks all [[shortcut bar]] items, including blueprint string import, copy & paste, deconstruction and upgrade planner.
| No
|-
| /unlock-tips
| /unlock-tips
| Unlocks all tips and tricks entries.
| No
|-
| /version
| /version
| Prints the current game version.
| No
|-
|}


Use the {{keybinding|&larr;}} and {{keybinding|&rarr;}} keys to cursor through the currently displayed message or command, which you can edit (delete, insert, etc.) and resend (by pressing '''Return''').
== Multiplayer commands ==
{| class="wikitable"
|-
! style="width:25%"| Command
! style="width:25%"| Example
! style="width:46%"| Description
! style="width:4%"| Admin only
|-
| <message>
| Hello team!
| Console input that does not start with {{keybinding|/}} 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
|-
| /bans
| /bans
| Prints a list of banned players.
| No
|-
| /banlist <add/remove/get/clear> <player>
| /banlist get
| Adds or removes a player from the banlist. Same as /ban or /unban.
| No
|-
| /config
| /config
| Opens the server configuration GUI.
| Yes
|-
| /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. The units for the options afk-auto-kick and autosave-interval are in minutes.
| 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
|-
| /p [online/o/count/c]
| /p o c
| Same as /players.
| 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 that's what I see
| Sends a message to the specified player.
| No
|-
| /w <player> <message>
| /w AzureDiamond that's 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
|}


In [https://forums.factorio.com/viewtopic.php?f=3&t=32389 Factorio 0.14.5 and later], the '''Tab''' key will auto-complete commands and player ids.
== Scripting and cheat commands ==
{| class="wikitable"
|-
! Command
! Description
|-
| /cheat [all/<planet-name>/<platform-name>/off]
| Researches all technologies and enables cheat mode (allowing free crafting of any item).  
* Using the '''all''' option also gives the player some additional items.
* Specifying a ''planet-name'' or ''platform-name'' also moves the player to the origin of the specified planet or platform.
* Using the '''off''' option turns cheat mode off.
|-
| /command <command>
| Executes a Lua command (if allowed).
|-
| /c <command>
| Executes a Lua command (if allowed).
|-
| /editor
| Toggles the map editor.
|-
| /measured-command <command>
| Executes a Lua command (if allowed) and measures time it took.
|-
| /mc <command>
| Executes a Lua command (if allowed) and measures time it took.
|-
| /silent-command <command>
| Executes a Lua command (if allowed) without printing it to the console.
|-
| /sc <command>
| Executes a Lua command (if allowed) without printing it to the console.
|}


== Multiplayer Chat ==
This is a very powerful feature, which also allows cheating, and as such <span style="color:#FF0000">achievements will be permanently disabled for the save</span> as soon as you use a script command.


Send private message to specific player with '''/whisper''' (or '''/w'''):
== Basic example scripts ==


/whisper <playerId> <message>
=== Use it as calculator ===
<syntaxhighlight lang="lua">
/c game.player.print(1234*5678)
</syntaxhighlight>


Reply to the most recently received private message with '''/reply''' (or '''/r'''):
=== Zoom beyond normal bounds ===
Note that zooming too far out can cause performance hits. Be careful.
<syntaxhighlight lang="lua">
/c game.player.zoom=0.1
</syntaxhighlight>


/reply <message>
=== Mine faster ===
<syntaxhighlight lang="lua">
/c game.player.force.manual_mining_speed_modifier=1000
</syntaxhighlight>


In [https://forums.factorio.com/viewtopic.php?f=3&t=32248 Factorio 0.14.4 and later], group chat works like this:
=== Craft faster ===
<syntaxhighlight lang="lua">
/c game.player.force.manual_crafting_speed_modifier=1000
</syntaxhighlight>


hello my team!
=== Unlock and research all technologies ===
<syntaxhighlight lang="lua">
/c game.player.force.research_all_technologies()
</syntaxhighlight>


/s hello all players!
Undo this with the command in the next section.
/shout same as /s


In Factorio 0.14.3 and earlier, group chat worked like this:
Note: Specific technologies can be researched using the [[map editor]] by shift clicking the "start research" button on the technology GUI.


hello all players!
=== Unresearch all technologies ===
This does not reset manually applied bonuses
<syntaxhighlight lang="lua">
/c for _, tech in pairs(game.player.force.technologies) do
tech.researched=false
end
</syntaxhighlight>


/team hello my team!
Note: Specific technologies can be unresearched using the [[map editor]] by clicking the "un-research" button on the technology GUI.


These are just the main chat features - there are also options for banning, ignoring and muting players; see the console '''/help''' for a full list.
=== Reset your force ===
This resets all data for your force, including kill and production statistics, technologies, bonuses and charting status.
<syntaxhighlight lang="lua">
/c game.player.force.reset()
</syntaxhighlight>


=== 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.


== Commands ==
<syntaxhighlight lang="lua">
To see a list of all available commands, enter '''/help''' (or '''/h''') in to the console. The available commands will depend on Factorio version and game setup.
/c game.player.game_view_settings.show_rail_block_visualisation = true
</syntaxhighlight>


/help
=== Set all trains to Automatic mode ===
Set all trains to automatic mode - for example after building them with a blueprint.


In [https://forums.factorio.com/viewtopic.php?f=3&t=32248 Factorio 0.14.4 and later], the '''/help''' command will just display a list of commands - to get full details for a command add the command name (without slash) after '''/help''' (or '''/h'''), for example if you want help on the '''/evolution''' command, you'd type:
<syntaxhighlight lang="lua">
/c for key,ent in pairs (game.player.surface.find_entities_filtered{name="locomotive"}) do
    ent.train.manual_mode = false
end
</syntaxhighlight>


/h evolution
== Inventory manipulation scripts ==


=== Scripting and cheat commands ===
=== Cheat mode ===
You can run Lua script commands via the console. It works similarly to any command line interface or the JavaScript console for your browser.
Allows for infinite free crafting. Disable by replacing true with false.
<syntaxhighlight lang="lua">
/c game.player.cheat_mode=true
</syntaxhighlight>


This is a very powerful feature, which also allows cheating, and as such <span style="color:#FF0000">achievements will be permanently disabled for the save</span> as soon as you use a script command.
=== Refill resources (refill oil, iron etc.) ===
While holding the cursor over a resource tile in-game:
<syntaxhighlight lang="lua">
/c game.player.selected.amount=7500
</syntaxhighlight>


To run a script, prefix it with '''/command''' (or '''/c'''), for example:
Alternatively you can refill all resources in the map with the following command. Change ore.amount to the desired value.
<syntaxhighlight lang="lua">
/c surface = game.player.surface
for _, ore in pairs(surface.find_entities_filtered({type="resource"})) do
    ore.amount = 10000
end
</syntaxhighlight>


/c game.player.print 'hello me!'
=== Add items to the player's inventory ===
Replace iron-plate with the [[data.raw|internal name]] of the item desired.
<syntaxhighlight lang="lua">
/c game.player.insert{name="iron-plate", count=100}
</syntaxhighlight>


If you're in a multiplayer game, the command will be echoed to all other players (so they can see if you're cheating).
For instance, here's a stack of the god-mode energy system interface:
<syntaxhighlight lang="lua">
/c game.player.insert{name="electric-energy-interface"}
</syntaxhighlight>


In [https://forums.factorio.com/viewtopic.php?p=203991#p203991 Factorio 0.14.5 and later], multiplayer server admins can use '''/silent-command''' (only via RCON/server console) instead of '''/c''' to avoid the command being echoed to all players.
There are several god-mode items available:


/silent-command game.player.print 'only admins can use (and see) silent commands'
* <code>infinity-chest</code>
* <code>infinity-pipe</code>
* <code>electric-energy-interface</code>
* <code>heat-interface</code>


Mod developers can also take advantage of the special '''/measured-command''' which is like '''/c''' but will time how long the command takes to run. This is very useful for performance tuning your scripts.
Add a powerful armor with equipment and some tools for construction:
<syntaxhighlight lang="lua">
/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 = "fission-reactor-equipment"})
p_armor.put({name = "fission-reactor-equipment"})
p_armor.put({name = "fission-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}
</syntaxhighlight>


/measured-command game.player.print 'how much time does this take to run?'
=== Increase player inventory slots ===
Gives 100 additional bonus inventory slots to your entire force. Used by the [[Toolbelt (research)]].
<syntaxhighlight lang="lua">
/c game.player.force.character_inventory_slots_bonus=100
</syntaxhighlight>


The game ignores newlines when pasting "scriptlets" in the console. This means they can be written in a human readable form in an editor and copy/pasted into the console, making understanding and editing a bit easier.
== World manipulation scripts ==


You can essentially fire any Lua command here, just as you would from a Lua program - Factorio [[Mods]] are merely Lua commands. Therefore you don't necessarily need "cheats" active per-se, as the console allows you full access to the game's internals. You only need a familiarity with the commands and types, as shown in the below examples and the [[Modding]] section.
=== Reveal the map around the player ===


Reveals the map around the player, similar to a [[radar]].
<syntaxhighlight lang="lua">
/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}})
</syntaxhighlight>
or from start position
<syntaxhighlight lang="lua">
/c local radius=150
game.player.force.chart(game.player.surface, {{x = -radius, y = -radius}, {x = radius, y = radius}})
</syntaxhighlight>
Change 150 to the desired radius, higher values take longer.


==Basic Command Examples==
=== Hide revealed map ===


=== Large Screenshots ===
Hides all revealed chunks, inverted map revealing.
<syntaxhighlight lang="lua">
/c local surface = game.player.surface
local force = game.player.force
for chunk in surface.get_chunks() do
  force.unchart_chunk({x = chunk.x, y = chunk.y}, surface)
end
</syntaxhighlight>


This is how you would take a large HD screenshot. As usual, replace the X and Y with the values you wish.
=== Reveal all generated map ===


The file is put into a folder called "script-output", which is located in the same location as the mods folder. These pictures can be quite large.
Revels all of the generated map to the player's team.
<syntaxhighlight lang="lua">
/c game.player.force.chart_all()
</syntaxhighlight>


/c game.take_screenshot{''<parameter>''=''<value>'',...}
=== 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.
<syntaxhighlight lang="lua">
/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
</syntaxhighlight>


The command takes the following parameters:
=== Delete unrevealed chunks ===
This command deletes chunks that are not revealed by the player. Can be used after the command for [[#Hide revealed map|hiding revealed map]] to delete the chunks not covered by radar.


* showgui - Boolean value, true or false. True if GUIs should be included in the screenshot.
<syntaxhighlight lang="lua">/c local surface = game.player.surface
* resolution - Takes an x and y, in the form {x = ''<x-size>'', y = ''<y-size>''}.
local force = game.player.force
* show_entity_info - Boolean value, true if alt info should be shown in the screenshot.
for chunk in surface.get_chunks() do
* zoom - The zoom level. 1 is normal, 2 is zoomed in to half the area, 0.5 is zoomed out to twice the area, etc.
  if not force.is_chunk_charted(surface, chunk) then
    surface.delete_chunk(chunk)
  end
end</syntaxhighlight>


=== Use it as calculator ===
=== Turn off night ===
Enables eternal day.
<syntaxhighlight lang="lua">
/c game.player.surface.always_day=true
</syntaxhighlight>


/c game.player.print(1234 * 5678)
=== 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.
<syntaxhighlight lang="lua">
/c game.speed=X
</syntaxhighlight>


=== Mine faster ===
=== Freeze time ===
Stops the advancement of the time. Unfreezes it if you by replace "true" with "false".
<syntaxhighlight lang="lua">
/c game.player.surface.freeze_daytime=true
</syntaxhighlight>


/c game.player.force.manual_mining_speed_modifier=1000
=== Remove all pollution ===
<syntaxhighlight lang="lua">
/c game.player.surface.clear_pollution()
</syntaxhighlight>


=== Craft faster ===
=== Completely turn off pollution ===


/c game.player.force.manual_crafting_speed_modifier=1000
<syntaxhighlight lang="lua">
/c for _, surface in pairs(game.surfaces) do
  surface.clear_pollution()
end
game.map_settings.pollution.enabled = false
</syntaxhighlight>


=== Unlock and Research all Technology ===
=== Add a lot of pollution ===
<syntaxhighlight lang="lua">
/c game.player.surface.pollute(game.player.position, 1000000)
</syntaxhighlight>


/c game.player.force.research_all_technologies()
=== Where speakers are, who placed them ===
<syntaxhighlight lang="lua">
/c local speakers = game.player.surface.find_entities_filtered{force = game.player.force, type="programmable-speaker"}
for key, speaker in pairs(speakers) do
    game.player.print(speaker.last_user.name .. " placed a speaker at " .. speaker.gps_tag)
end
</syntaxhighlight>


Undo this with:
=== Disable friendly fire for your force ===
<syntaxhighlight lang="lua">
/c game.player.force.friendly_fire = false
</syntaxhighlight>


/c for _, tech in pairs(game.player.force.technologies) do tech.researched=false end
=== 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.


=== Reset any modifiers to default ===
If you want a larger patch, change "local size = 5" to a larger number.
This includes Tech and speed alterations.
A larger patch will have exponentially more ore.
Entering a number above 30 is not recommended.


/c game.player.force.reset()
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.


=== Zoom beyond normal bounds ===
To choose which resource is spawned, change "stone" near the bottom to "iron-ore", "copper-ore", "coal", or "uranium-ore".
Note that zooming too far out can cause performance hits. Be careful.


/c game.player.zoom = 0.1
<syntaxhighlight lang="lua">
/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
</syntaxhighlight>


For more flexibility, the [[map editor]] can also be used to create/alter/remove resource patches.


== Inventory Manipulation ==
=== Remove resources around the player ===
Removes all resource patches from the ground in a 50 x 50 area around the player.


=== Refill resources (refill oil, iron etc.) ===
<syntaxhighlight lang="lua">
While holding the cursor over a resource tile in-game
/c local surface=game.player.surface
/c game.player.selected.amount=7500
local size=50
local pos=game.player.position


=== Add items to the player's inventory ===
for _, e in pairs(surface.find_entities_filtered{area={{pos.x-size, pos.y-size},{pos.x+size, pos.y+size}}, type="resource"})
Replace iron-plate with the internal name of the item desired.
do e.destroy()
end
</syntaxhighlight>


/c game.player.insert{name="iron-plate", count=100}
=== Add new oil patch ===
This creates 9 crude oil patches in a 3×3 square.
<syntaxhighlight lang="lua">
/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
</syntaxhighlight>


For instance, here's a god-mode energy system interface:
or randomly without any collision:
<syntaxhighlight lang="lua">
/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
</syntaxhighlight>


/c game.player.insert{name="electric-energy-interface"}
=== Add new water patch ===


=== Cheat mode ===
This creates a small pond in a 4x2 square.
Allows for infinite free crafting. Disable by replacing true with false.
<syntaxhighlight lang="lua">
/c
local waterTiles = {}
for y=2,4 do
for x=-2,2 do
  table.insert(waterTiles, {name="water", position={game.players[1].position.x+x, game.players[1].position.y+y}})
end
game.players[1].surface.set_tiles(waterTiles)
end
</syntaxhighlight>


/c game.player.cheat_mode=true
=== Regenerate resources ===
For solid resources like iron, destroys all resource entities and creates resource entities as in the original map generation. For fluid resources like oil, sets the yield of all existing resource entities to the original amount. Regenerates resources on the entire surface.
<syntaxhighlight lang="lua">
/c local surface = game.player.surface
for _, e in pairs(surface.find_entities_filtered{type="resource"}) do
  if e.prototype.infinite_resource then
    e.amount = e.initial_amount
  else
    e.destroy()
  end
end
local non_infinites = {}
for resource, prototype in pairs(prototypes.get_entity_filtered{{filter="type", type="resource"}}) do
  if not prototype.infinite_resource then
    table.insert(non_infinites, resource)
  end
end
surface.regenerate_entity(non_infinites)
for _, e in pairs(surface.find_entities_filtered{type="mining-drill"}) do
    e.update_connections()
end
</syntaxhighlight>


=== Count entities ===
Counts all entities whose name includes the string in local entity.
<syntaxhighlight lang="lua">
/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)
</syntaxhighlight>


== World Manipulation ==
=== 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.
=== 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}})
 
Change 150 to the desired radius, higher values take longer.


=== Turn off night ===
<syntaxhighlight lang="lua">
Enables eternal day.
/c local mgs = game.player.surface.map_gen_settings
/c game.surfaces[1].always_day=true
mgs.cliff_settings.cliff_elevation_0 = 1024
game.player.surface.map_gen_settings = mgs</syntaxhighlight>


=== Change game speed ===
=== Remove all cliffs ===
0.5 is half speed, 1 is default, 2 is double speed, etc. Minimum is 0.1. 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.
Removes all cliffs existing cliffs from the world. Use [[#Turn off cliff generation]] to turn off cliff generation in new chunks.


/c game.speed = X
<syntaxhighlight lang="lua">
/c for _, v in pairs(game.player.surface.find_entities_filtered{type="cliff"}) do
  v.destroy()
end</syntaxhighlight>


=== Freeze Time Passage ===
=== Delete all decoratives ===
Stops the advancement of the time if you replace "BOOL" with "true" or unfreezes it if you replace it with "false".
Delete the decoratives that can be found in the world.


/c game.player.surface.freeze_daytime(BOOL)
<syntaxhighlight lang="lua">
/c game.player.surface.destroy_decoratives({})</syntaxhighlight>


=== Remove all pollution ===
=== Change map generation settings ===
This allows to change the map generation settings for new chunks; it does not alter already generated chunks. [[#Delete chunks|Deleted chunks]] are affected by the setting change because they are newly generated when they get explored again.


/c local surface = game.player.surface;
To change resource generation settings, replace "iron-ore" with the [[Data.raw#resource|resource]] that should be changed and replace "very-high" with the desired [https://lua-api.factorio.com/latest/Concepts.html#MapGenSize MapGenSize] in the following command. Replace "iron-ore" with "enemy-base" to change the enemy base generation settings.  
for coord in surface.get_chunks() do
  surface.pollute({coord.x * 32, coord.y * 32}, -10000000)
end


=== Add new resource patch ===
<syntaxhighlight lang="lua">
This creates a new 11x11 patch of resources, centered on the player character. 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.
/c local surface = game.player.surface
local resource = "iron-ore"
local mgs = surface.map_gen_settings
mgs.autoplace_controls[resource].size = "very-high"
mgs.autoplace_controls[resource].frequency = "very-high"
mgs.autoplace_controls[resource].richness = "very-high"
surface.map_gen_settings = mgs</syntaxhighlight>


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.
To change water generation settings, replace "very-high" with the desired [https://lua-api.factorio.com/latest/Concepts.html#MapGenSize MapGenSize] in the following command.


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.
<syntaxhighlight lang="lua">
/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 </syntaxhighlight>


To choose which resource is spawned, change "stone" near the bottom to "iron-ore", "copper-ore", "coal", or "uranium-ore".  
=== Making a structure indestructible ===
This makes it impossible for an entity to be damaged or killed, e.g. by biters. Hover over the entity and then run:
<syntaxhighlight lang="lua">
/c game.player.selected.destructible = false
</syntaxhighlight>


/c local surface = game.player.surface;
=== Connect linked belts ===
local ore = nil
If there exist at least two [https://lua-api.factorio.com/latest/prototypes/LinkedBeltPrototype.html linked belts], and one of them has the "Entity tag" <code>in</code>, and another linked belt has the "Entity tag" <code>out</code>, then the following command should link these two linked belts.
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
  surface.create_entity({name="stone", amount=ore, position={game.player.position.x+x, game.player.position.y+y}})
  end
end


=== Add new oil patch ===
<syntaxhighlight lang="lua">
This creates 9 crude oil patches in a 3x3 square.
/c local i = game.get_entity_by_tag('in')
local o = game.get_entity_by_tag('out')
i.linked_belt_type = 'input'
o.linked_belt_type = 'output'
i.connect_linked_belts(o)
</syntaxhighlight>


/c for y=0,2 do
== Enemy/evolution scripts ==
  for x=0,2 do
    game.player.surface.create_entity({name="crude-oil", amount=5000, 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=5000, position=position})
end
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 c in surface.get_chunks() do
  for key, ent in pairs(surface.find_entities_filtered({area={{c.x * 32, c.y * 32}, {c.x * 32 + 32, c.y * 32 + 32}}, force= game.player.force})) do
    if string.find(ent.name,entity) then
      count = count + 1
    end
  end
end
game.player.print(count)
 
== Enemy/Evolution ==
=== Check how far the biters have evolved ===
Note that commands that do not start with "/c" do not disable achievements.
/evolution


=== Set evolution factor ===
=== Set evolution factor ===
Ranges from 0 (new game) to 1.
Ranges from 0 (new game) to 1.
 
<syntaxhighlight lang="lua">
/c game.evolution_factor=X
/c game.forces["enemy"].set_evolution_factor(X, game.player.surface)
 
</syntaxhighlight>
In 0.15, use the following command instead:
 
/c game.forces["enemy"].evolution_factor=X


=== Disable time-based evolution & increases pollution-based evolution ===
=== Disable time-based evolution & increases pollution-based evolution ===
/c game.map_settings.enemy_evolution.time_factor = 0
<syntaxhighlight lang="lua">
/c game.map_settings.enemy_evolution.pollution_factor = game.map_settings.enemy_evolution.pollution_factor * 2
/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
</syntaxhighlight>


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.
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 ===
=== Kill all biters on the "enemy" force ===
Note that this will kill only mobile units and worms, spawners will not be killed.
Note that this will kill only mobile units, spawners will not be killed.
/c game.forces["enemy"].kill_all_units()
<syntaxhighlight lang="lua">
/c game.forces["enemy"].kill_all_units()
</syntaxhighlight>


=== Kill all enemies ===
=== 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.
This will kill all biters, bases and worms. Anything that is an enemy will be completely destroyed. This only affects enemies in the generated 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|prevent biters being on newly generated chunks]] if desired.
<syntaxhighlight lang="lua">
/c local surface=game.player.surface
for key, entity in pairs(surface.find_entities_filtered({force="enemy"})) do
entity.destroy()
end
</syntaxhighlight>
 
=== 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 surface = game.player.surface
<syntaxhighlight lang="lua">
for c in surface.get_chunks() do
/c local surface=game.player.surface
    for key, entity in pairs(surface.find_entities_filtered({area={{c.x * 32, c.y * 32}, {c.x * 32 + 32, c.y * 32 + 32}}, force= "enemy"})) do
local pp = game.player.position
        entity.destroy()
local cnt = 0
    end
for key, entity in pairs(surface.find_entities_filtered({force="enemy", radius=250, position=pp })) do
  end
cnt = cnt+1
entity.destroy()
end
game.player.print(cnt)
</syntaxhighlight>
 
=== 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.
<syntaxhighlight lang="lua">
/c game.player.surface.peaceful_mode = true
</syntaxhighlight>
 
=== Enable/Disable biter expansion ===
Biter expansion allows biters to create new nests, it is enabled by default. Substitute true for false to disable.
<syntaxhighlight lang="lua">
/c game.map_settings.enemy_expansion.enabled = true
</syntaxhighlight>


=== Enable peaceful mode ===
=== Prevent biters being on newly generated chunks ===
Peaceful mode prevents biter attacks until provoked. Substitute false for true to disable.
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 [[#Change map generation settings|changing map generation settings]].
/c game.player.surface.peaceful_mode = true
<syntaxhighlight lang="lua">
/c local surface = game.player.surface
local mgs = surface.map_gen_settings
mgs.autoplace_controls["enemy-base"].size = "none"
surface.map_gen_settings = mgs
</syntaxhighlight>


=== Disable biter expansion ===
Instead of the command, it is also possible to use a GUI in the [[map editor]] to changing map generation settings mid game. Access the map editor with <code>/editor</code>, go to the "Surfaces" tab and click "Edit map gen settings".
This prevents biters from creating new spawners.
/c game.map_settings.enemy_expansion.enabled = false


== Player Character ==
== Player character scripts ==
Commands concerning the player directly.
Commands concerning the player directly.
=== Get Player Position ===
=== Get player position ===
Prints coordinates of your current position.
Prints coordinates of your current position.
 
<syntaxhighlight lang="lua">
/c game.player.print({"", "(", game.player.position.x, ", ", game.player.position.y, ")"})
/c game.player.print(game.player.position)
</syntaxhighlight>


=== Teleport player ===
=== 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.
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.
 
<syntaxhighlight lang="lua">
/c game.player.teleport({X, Y})
/c game.player.teleport({X, Y})
</syntaxhighlight>


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


=== Spawn a player character ===
To teleport to a different planet / surface, use:
This is useful for escaping god mode. (see [[Console#Enable_god_mode]].) This will spawn a new player at the spawn point of the world, and connect your controls to it.
<syntaxhighlight lang="lua">
 
/c game.player.teleport({X, Y}, 'surface_name')
/c game.player.character = game.player.surface.create_entity{name="player", position = {0,0}, force = game.forces.player}
</syntaxhighlight>
 
=== Change Player color ===
Note that commands that do not start with "/c" do not disable achievements. Replace COLOR with the name of a color. Available names are: Black, blue, brown, cyan, gray, green, orange, pink, purple, red, white, and yellow
/color COLOR


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


Disassociate your controls from the player:
Disassociate your controls from the character and destroy it:
 
<syntaxhighlight lang="lua">
/c game.player.character = nil
/c game.player.character.destroy()
</syntaxhighlight>


Then, hover the mouse over the useless player and destroy it by typing:
To undo, spawn a player character. This will spawn a new character at the spawn point of the world, and connect your controls to it.
<syntaxhighlight lang="lua">
/c game.player.create_character()
</syntaxhighlight>


/c game.player.selected.destroy()
=== 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
game.player.force.character_resource_reach_distance_bonus = reach
game.player.force.character_item_drop_distance_bonus = reach
</syntaxhighlight>


To undo
=== Find player corpses ===
Pings player corpses on the map.
<syntaxhighlight lang="lua">
/c local found_corpses = game.player.surface.find_entities_filtered{type="character-corpse"}
for _,corpse in pairs(found_corpses) do
    local player = game.get_player(corpse.character_corpse_player_index)
    local name = player and player.name or "????"
    game.player.print(name .. " --> " .. corpse.gps_tag)
end
</syntaxhighlight>


/c game.player.create_character()
=== Run faster ===
<syntaxhighlight lang="lua">
/c game.player.character_running_speed_modifier=3
</syntaxhighlight>


== Research ==
== Research scripts ==
=== Enable faster research ===
=== Enable faster research ===
/c game.player.force.laboratory_speed_modifier = 1
<syntaxhighlight lang="lua">
1 is normal speed, 2 is double speed 3 is triple etc. I think it goes up to 100.
/c game.player.force.laboratory_speed_modifier=1
</syntaxhighlight>
-0.5 is half speed, 0 is normal speed, 1 is double speed, 2 is triple etc.


=== Enabling specific technologies ===
=== Research specific technologies ===
[http://www.factorioforums.com/forum/viewtopic.php?f=18&t=6633 Enabling technologies] (forums)
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
<syntaxhighlight lang="lua">
/c game.player.force.technologies['steel-processing'].researched=true
/c game.player.force.technologies['electric-energy-distribution-1'].researched=true
/c game.player.force.technologies['steel-processing'].researched=true
</syntaxhighlight>


=== Enabling specific recipes ===
To research a high level of an infinite technology, set its level:
/c game.player.force.recipes["electric-energy-interface"].enabled = true
<syntaxhighlight lang="lua">
/c game.player.force.recipes["rocket-silo"].enabled = true
/c game.player.force.technologies['worker-robots-speed-6'].level = 100
/c game.player.force.technologies['mining-productivity-4'].level = 100
</syntaxhighlight>


=== Finish research immediately ===
=== Unresearch specific technologies ===
/c for name,technology in pairs(game.player.force.technologies) do technology.researched=technology.enabled end
The internal technology names can be found in the infoboxes on their respective pages.
<syntaxhighlight lang="lua">
/c game.player.force.technologies['electric-energy-distribution-1'].researched=false
/c game.player.force.technologies['steel-processing'].researched=false
</syntaxhighlight>


== Command Line Parameters ==
=== Enabling specific recipes ===
'''As of Game Version 0.14.21'''
The internal recipe/item names can be found in the infoboxes on their respective pages.
<syntaxhighlight lang="lua">
/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
/c game.player.force.recipes["fast-loader"].enabled = true
/c game.player.force.recipes["express-loader"].enabled = true
</syntaxhighlight>


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.
=== Enable all recipes ===
<syntaxhighlight lang="lua">
/c for name, recipe in pairs(game.player.force.recipes) do recipe.enabled = true end
</syntaxhighlight>


General options:
=== Resetting technology effects to default ===
  -h [ --help ]                      display help
This will reset the enabled/unlocked state of all recipes to what they would be purely based on the currently researched technologies, as well as resetting other technology effects like mining speed, etc. Any manual modifications to these effects and recipe unlocks will be undone.
  --version                          show version information
<syntaxhighlight lang="lua">
  -v [ --verbose ]                  enable verbose logging
/c game.player.force.reset_technology_effects()
  -c [ --config ] PATH              config file to use
</syntaxhighlight>
  --no-log-rotation                  don't rotate log file
Note: Can be used as a quick workaround when recipes are unavailable after adding or changing mods even though the technology unlocking them has already been researched.
  --mod-directory PATH              Mod directory to use


Running options:
== Modding tools ==
  -s [ --map2scenario ] arg          map to scenario conversion
A list of the internal names of most things in the vanilla game can also be found on [[data.raw]].
  -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. See data/map-gen-settings.exampl
                                    e.json
  --start-server FILE                start a multiplayer server
  --start-server-load-scenario FILE  start a multiplayer server and load the
                                    specified scenario
  --start-server-load-latest        start a multiplayer server and load the
                                    latest available save
  --until-tick TICK                  run a save until given map tick
  --mp-connect ADDRESS              start factorio and connect to address
  --load-game FILE                  start Factorio and load a game in
                                    singleplayer
  --benchmark FILE                  load save and run benchmark
  --benchmark-ticks N (=1,000)      number of ticks for benchmarking. Default
                                    is 1000
  --force-opengl                    use OpenGL for rendering
  --force-d3d                        use Direct3D for rendering


Server options:
=== Access a mod's data ===
  --port N                          network port to use
If the first word of the command is __mod-name__ it will run in the context of the mod with the same name. For instance, this command prints the data from the Even Distribution mod:
  --bind ADDRESS[:PORT]              IP address (and optionally port) to bind
<syntaxhighlight lang="lua">
                                    to
/c __even-distribution__ game.player.print(serpent.dump(global))
  --rcon-port N                      Port to use for RCON
</syntaxhighlight>
  --rcon-password PASSWORD          Password for RCON
  --server-settings FILE            Path to file with server settings. See
                                    data/server-settings.example.json


=== Print to console the tile under the player ===
<syntaxhighlight lang="lua">
/c game.player.print(game.player.surface.get_tile(game.player.position).name)
</syntaxhighlight>


'''As of Game Version 0.15.13'''<br/>
=== Write all researched technologies to file ===
0.15.x Adds in a couple of new command line options.
<syntaxhighlight lang="lua">
/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)
</syntaxhighlight>


General options:
=== Write all enabled recipes to file ===
  -h [ --help ]                      display help
<syntaxhighlight lang="lua">
  --version                          show version information
/c local list = {}
  -v [ --verbose ]                  enable verbose logging
for _, recipe in pairs(game.player.force.recipes) do
  -c [ --config ] PATH              config file to use
if recipe.enabled then
  --no-log-rotation                  don't rotate log file
    list[#list+1] = recipe.name
  --mod-directory PATH              Mod directory to use
   end
  --check-unused-prototype-data      Print a warning for all prototype values that were not accessed
end
 
game.write_file("recipes.lua", serpent.block(list) .. "\n", true)
Running options:
</syntaxhighlight>
  -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. See data/map-gen-settings.example.json
  --map-settings FILE                Map settings for use with --create. See data/base/prototypes/map-settings.lua
  --preset arg                      Name of the map generation preset to be used.
  --generate-map-preview FILE        Generate preview images of the map
  --map-preview-size SCALE (=1,024)  Size (in pixels) of map preview
  --map-preview-scale SCALE (=1)    Scale (meters per pixel) of map preview
  --map-preview-offset X,Y (=0,0)    Offset of the center of the map, in meters
  --start-server FILE                start a multiplayer server
  --start-server-load-scenario FILE  start a multiplayer server and load the specified scenario
  --start-server-load-latest        start a multiplayer server and load the latest available save
  --until-tick TICK                  run a save until given map tick
  --mp-connect ADDRESS              start factorio and connect to address
  --load-game FILE                  start Factorio and load a game in singleplayer
  --benchmark FILE                  load save and run benchmark
  --benchmark-ticks N (=1,000)      number of ticks for benchmarking. Default is 1000
  --force-opengl                    use OpenGL for rendering
  --force-d3d                        use Direct3D for rendering
  --fullscreen BOOL                  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
  --gfx-safe-mode                    resets some graphics settings to values that should work on most configurations
  --shader arg                      enable/disable shader postprocessing (saved to configuration)
  --disable-audio                    Disable audio. Mainly for faster startup during development.
 
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 ===
 
  --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
=== Write mod list to file ===
  ./factorio --mp-connect 192.168.1.101:2345
Write all currently active mods and their version to the file script-output/mods.txt in the [[user data directory]].


As above, port can be specified by placing the port number after a colon in the address.
<syntaxhighlight lang="lua">
/c helpers.write_file("mods.txt", serpent.block(script.active_mods))
</syntaxhighlight>


  --map2scenario SAVE
== History ==
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.
{{History|1.1.92|
* Added a notification when a technology is researched.
* Added /enable-research-queue console command to enable the research queue without disabling achievements.}}


== See also ==
== See also ==
* [[Command line parameters]]
* https://lua-api.factorio.com/latest/index-runtime.html - Factorio API reference for latest version


* http://lua-api.factorio.com/latest/ - Factorio API reference for latest version
{{C|Modding}}
* http://lua-api.factorio.com/ - links to specific versions of API reference
[[Category:Console]]

Latest revision as of 19:42, 22 November 2024

The console is Factorio's in-game command-line interface. See command line parameters for the command line interface of the Factorio executable.

The in-game console can be used for:

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

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 GRAVE key (`). This is the key located to the left of the 1 key, above Tab.

You can customize the keys via Settings menu → Controls → Toggle chat (and 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 the console.

When the 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. The fade-out time can be changed via Settings menu → Interface → Chat message delay.

The console can be cleared with the /clear command.

Use the and keys to scroll through the console history. The Tab key provides intelligent code completion on commands, options and player names.

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, train_out_of_fuel, fluid_mixing. No
/clear /clear Clears the console. No
/color <color> /color 20 255 255 Changes your color. Can either be one of the pre-defined colors or RGB 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
/permissions <action> <parameters> /permissions add-player DeveloperGroup kovarex Available actions are add-player <group> <player>, create-group <name>, delete-group <group>, edit-group <group> <input_action> <true/false>, get-player-group <player>, remove-player <group> <player>, rename-group <group> <new_name> and reset Yes
/reset-tips /reset-tips Resets the state of the tips and tricks as if the game was just started for the first time. No
/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
/unlock-shortcut-bar /unlock-shortcut-bar Unlocks all shortcut bar items, including blueprint string import, copy & paste, deconstruction and upgrade planner. No
/unlock-tips /unlock-tips Unlocks all tips and tricks entries. 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
/bans /bans Prints a list of banned players. No
/banlist <add/remove/get/clear> <player> /banlist get Adds or removes a player from the banlist. Same as /ban or /unban. No
/config /config Opens the server configuration GUI. Yes
/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. The units for the options afk-auto-kick and autosave-interval are in minutes. 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
/p [online/o/count/c] /p o c Same as /players. 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 that's what I see Sends a message to the specified player. No
/w <player> <message> /w AzureDiamond that's 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/<planet-name>/<platform-name>/off] Researches all technologies and enables cheat mode (allowing free crafting of any item).
  • Using the all option also gives the player some additional items.
  • Specifying a planet-name or platform-name also moves the player to the origin of the specified planet or platform.
  • Using the off option turns cheat mode off.
/command <command> Executes a Lua command (if allowed).
/c <command> Executes a Lua command (if allowed).
/editor Toggles the map editor.
/measured-command <command> Executes a Lua command (if allowed) and measures time it took.
/mc <command> Executes a Lua command (if allowed) and measures time it took.
/silent-command <command> Executes a Lua command (if allowed) without printing it to the console.
/sc <command> Executes a Lua command (if allowed) 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.

Note: Specific technologies can be researched using the map editor by shift clicking the "start research" button on the technology GUI.

Unresearch all technologies

This does not reset manually applied bonuses

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

Note: Specific technologies can be unresearched using the map editor by clicking the "un-research" button on the technology GUI.

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

Set all trains to Automatic mode

Set all trains to automatic mode - for example after building them with a blueprint.

/c for key,ent in pairs (game.player.surface.find_entities_filtered{name="locomotive"}) do 
    ent.train.manual_mode = false
end

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"}

There are several god-mode items available:

  • infinity-chest
  • infinity-pipe
  • electric-energy-interface
  • heat-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 = "fission-reactor-equipment"})
	p_armor.put({name = "fission-reactor-equipment"})
	p_armor.put({name = "fission-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}

Increase player inventory slots

Gives 100 additional bonus inventory slots to your entire force. Used by the Toolbelt (research).

/c game.player.force.character_inventory_slots_bonus=100

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 local radius=150
game.player.force.chart(game.player.surface, {{x = -radius, y = -radius}, {x = radius, y = radius}})

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

Hide revealed map

Hides all revealed chunks, inverted map revealing.

/c local surface = game.player.surface
local force = game.player.force
for chunk in surface.get_chunks() do
  force.unchart_chunk({x = chunk.x, y = chunk.y}, surface)
end

Reveal all generated map

Revels all of the generated map to the player's team.

/c game.player.force.chart_all()

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

Delete unrevealed chunks

This command deletes chunks that are not revealed by the player. Can be used after the command for hiding revealed map to delete the chunks not covered by radar.

/c local surface = game.player.surface
local force = game.player.force
for chunk in surface.get_chunks() do
  if not force.is_chunk_charted(surface, chunk) 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

Freeze time

Stops the advancement of the time. Unfreezes it if you by replace "true" with "false".

/c game.player.surface.freeze_daytime=true

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, who placed them

/c local speakers = game.player.surface.find_entities_filtered{force = game.player.force, type="programmable-speaker"}
for key, speaker in pairs(speakers) do
    game.player.print(speaker.last_user.name .. " placed a speaker at " .. speaker.gps_tag)
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

For more flexibility, the map editor can also be used to create/alter/remove resource patches.

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

Add new water patch

This creates a small pond in a 4x2 square.

/c
local waterTiles = {}
for y=2,4 do
 for x=-2,2 do
  table.insert(waterTiles, {name="water", position={game.players[1].position.x+x, game.players[1].position.y+y}})
 end
 game.players[1].surface.set_tiles(waterTiles)
end

Regenerate resources

For solid resources like iron, destroys all resource entities and creates resource entities as in the original map generation. For fluid resources like oil, sets the yield of all existing resource entities to the original amount. Regenerates resources on the entire surface.

/c local surface = game.player.surface
for _, e in pairs(surface.find_entities_filtered{type="resource"}) do
  if e.prototype.infinite_resource then
    e.amount = e.initial_amount
  else
    e.destroy()
  end
end
local non_infinites = {}
for resource, prototype in pairs(prototypes.get_entity_filtered{{filter="type", type="resource"}}) do
  if not prototype.infinite_resource then
    table.insert(non_infinites, resource)
  end
end
surface.regenerate_entity(non_infinites)
for _, e in pairs(surface.find_entities_filtered{type="mining-drill"}) do
    e.update_connections()
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)

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 game.player.surface.destroy_decoratives({})

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 mgs = surface.map_gen_settings
mgs.autoplace_controls[resource].size = "very-high"
mgs.autoplace_controls[resource].frequency = "very-high"
mgs.autoplace_controls[resource].richness = "very-high"
surface.map_gen_settings = mgs

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

Making a structure indestructible

This makes it impossible for an entity to be damaged or killed, e.g. by biters. Hover over the entity and then run:

/c game.player.selected.destructible = false

Connect linked belts

If there exist at least two linked belts, and one of them has the "Entity tag" in, and another linked belt has the "Entity tag" out, then the following command should link these two linked belts.

/c local i = game.get_entity_by_tag('in')
local o = game.get_entity_by_tag('out')
i.linked_belt_type = 'input'
o.linked_belt_type = 'output'
i.connect_linked_belts(o)

Enemy/evolution scripts

Set evolution factor

Ranges from 0 (new game) to 1.

/c game.forces["enemy"].set_evolution_factor(X, game.player.surface)

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 generated 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 surface=game.player.surface
local pp = game.player.position
local cnt = 0
for key, entity in pairs(surface.find_entities_filtered({force="enemy", radius=250, position=pp })) do
	cnt = cnt+1
	entity.destroy()
 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

Instead of the command, it is also possible to use a GUI in the map editor to changing map generation settings mid game. Access the map editor with /editor, go to the "Surfaces" tab and click "Edit map gen settings".

Player character scripts

Commands concerning the player directly.

Get player position

Prints coordinates of your current position.

/c game.player.print(game.player.position)

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.

To teleport to a different planet / surface, use:

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

Enable god mode

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

Disassociate your controls from the character and destroy it:

/c game.player.character.destroy()

To undo, spawn a player character. This will spawn a new character 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
game.player.force.character_resource_reach_distance_bonus = reach
game.player.force.character_item_drop_distance_bonus = reach

Find player corpses

Pings player corpses on the map.

/c local found_corpses = game.player.surface.find_entities_filtered{type="character-corpse"}
for _,corpse in pairs(found_corpses) do
    local player = game.get_player(corpse.character_corpse_player_index)
    local name = player and player.name or "????"
    game.player.print(name .. " --> " .. corpse.gps_tag)
end

Run faster

/c game.player.character_running_speed_modifier=3

Research scripts

Enable faster research

/c game.player.force.laboratory_speed_modifier=1

-0.5 is half speed, 0 is normal speed, 1 is double speed, 2 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

To research a high level of an infinite technology, set its level:

/c game.player.force.technologies['worker-robots-speed-6'].level = 100
/c game.player.force.technologies['mining-productivity-4'].level = 100

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
/c game.player.force.technologies['steel-processing'].researched=false

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
/c game.player.force.recipes["fast-loader"].enabled = true
/c game.player.force.recipes["express-loader"].enabled = true

Enable all recipes

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

Resetting technology effects to default

This will reset the enabled/unlocked state of all recipes to what they would be purely based on the currently researched technologies, as well as resetting other technology effects like mining speed, etc. Any manual modifications to these effects and recipe unlocks will be undone.

/c game.player.force.reset_technology_effects()

Note: Can be used as a quick workaround when recipes are unavailable after adding or changing mods even though the technology unlocking them has already been researched.

Modding tools

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

Access a mod's data

If the first word of the command is __mod-name__ it will run in the context of the mod with the same name. For instance, this command prints the data from the Even Distribution mod:

/c __even-distribution__ game.player.print(serpent.dump(global))

Print to console the tile under the player

/c game.player.print(game.player.surface.get_tile(game.player.position).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)

Write mod list to file

Write all currently active mods and their version to the file script-output/mods.txt in the user data directory.

/c helpers.write_file("mods.txt", serpent.block(script.active_mods))

History

  • 1.1.92:
    • Added a notification when a technology is researched.
    • Added /enable-research-queue console command to enable the research queue without disabling achievements.

See also