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

Console: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
No edit summary
m (→‎Remove all pollution: updated code)
(45 intermediate revisions by 14 users not shown)
Line 1: Line 1:
{{Languages}}
{{Languages}}


{{stub|This article needs to be completely rewritten.}}
== Overview ==
The in-game console is used for:


The console is the built in interface for lua-commands. It works a bit like any command-line-interface or the java-script-console for your browser.
* Chatting with other players
* Running commands / scripts / cheats
* Occasional status updates


Basically you can fire here all commands, like from any other lua-program (= [[Modding]]). This means you have full access to all in-game-internals.
There are three types of command:


In other words: Factorio doesn't need any special cheats, it has a console, which allows you to cheat around any limition, if you know how.
* '''Multiplayer''' - message filtering, banning users, etc.
* '''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>)


== How to open the console? ==
=== Using the console ===
The console display can be toggled with the {{keybinding|/}} (slash) or {{keybinding|~}} (tilde) keys.


You open the console by default with the key''' '/' or '~''''. This is the chat window in multiplayer! The prefix for Lua commands is '/c'.  
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.


To change that key go into the keyboard control and change "Toggle Lua console" to a useful key.
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'''.


=== Change in v0.11 ===
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.


You need to type '/c' in front of your commands. Otherwise it is just a chat message.
Note that the console can also accept raw Lua code as well as game commands.


=== Editing ===
=== Console history ===


The console has an inbuilt history. You can use the "cursor-up"-key to edit/repeat the previous commands.
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 {{keybinding|&uarr;}} and {{keybinding|&darr;}} keys to scroll through the console history.
 
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''').
 
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.
 
== Multiplayer Chat ==
 
Send private message to specific player with '''/whisper''' (or '''/w'''):
 
/whisper <playerId> <message>
 
Reply to the most recently received private message with '''/reply''' (or '''/r'''):
 
/reply <message>
 
In [https://forums.factorio.com/viewtopic.php?f=3&t=32248 Factorio 0.14.4 and later], group chat works like this:
 
hello my team!
 
/s hello all players!
/shout same as /s
 
In Factorio 0.14.3 and earlier, group chat worked like this:
 
hello all players!
 
/team hello my team!
 
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.
 
 
== Commands ==
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.
 
/help
 
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:
 
/h evolution
 
=== Scripting and cheat commands ===
You can run Lua script commands via the console. It works similarly to any command line interface or the JavaScript console for your browser.
 
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.
 
To run a script, prefix it with '''/command''' (or '''/c'''), for example:
 
/c game.player.print 'hello me!'
 
If you're in a multiplayer game, the command will be echoed to all other players (so they can see if you're cheating).
 
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.
 
/silent-command game.player.print 'only admins can use (and see) silent commands'
 
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.
 
/measured-command game.player.print 'how much time does this take to run?'


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


On the other hand, if you want to type ''several commands in one line'' you just need to put ';' (semicolon) between the commands - see examples down below.
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.
 
 
==Basic Command Examples==
 
=== Large Screenshots ===
 
This is how you would take a large HD screenshot. As usual, replace the X and Y with the values you wish.
 
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.
 
/c game.take_screenshot{<parameters>}
 
The command takes the following parameters, separated by commas:
 
* showgui - Boolean value, true or false. True if GUIs should be included in the screenshot.
* resolution - Takes an x and y, in the form {x = XPOS, y = YPOS}
* show_entity_info - Boolean value, true if alt info should be shown in the screenshot.
* zoom - A value to take the screenshot from a certain zoom.
 
=== Use it as calculator ===
 
/c game.player.print(1234 * 5678)
 
=== 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 Technology ===
 
/c game.player.force.research_all_technologies()
 
Undo this with:
 
/c for _, tech in pairs(game.player.force.technologies) do tech.researched=false end
 
=== Reset any modifiers to default ===
This includes Tech and speed alterations.
 
/c game.player.force.reset()
 
=== Zoom beyond normal bounds ===
Note that zooming too far out can cause performance hits. Be careful.
 
/c game.player.zoom = 0.1
 
 
== Inventory Manipulation ==
 
=== Refill resources (refill oil, iron etc.) ===
While holding the cursor over a resource tile in-game
/c game.player.selected.amount=7500
 
=== 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}
 
=== Cheat mode ===
Allows for infinite free crafting. Disable by replacing true with false.
 
/c game.player.cheat_mode=true
 
 
== World Manipulation ==
 
=== Reveal the map around the player ===


== Useful commands (cheats) ==
Reveals the map around the player, similar to a [[radar]].


The 0.12.x updated added a _ to a the majority of the methods and properties.
  /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}})


* Remove all enemies from the map
Change 150 to the desired radius, higher values take longer.
    /c local surface = game.local_player.surface
    for c in surface.get_chunks() do
        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
            entity.destroy()
        end
    end


* Use it as command-line-calculator (see above: you can repeat command with the "cursor up"-key!)
=== Turn off night ===
  /c game.local_player.print(1234 * 5678)
Enables eternal day.
  /c game.surfaces[1].always_day=true


* Check how far the biters have evolved
=== Change game speed ===
/c game.local_player.print(game.evolution_factor)
0.5 is half speed, 1 is default, 2 is double speed, etc. 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.


* Turn off night
  /c game.speed = X
  /c game.always_day=true


* Zoom out to place blueprints, that are bigger than your screen.
=== Freeze Time Passage ===
/c game.local_player.zoom = 0.1
Stops the advancement of the time if true is passed, or unfreezes it if false is passed.


* Kill all biters on the "enemy" force
  /c game.player.surface.freeze_daytime(BOOL)
  /c game.forces["enemy"].kill_all_units()


* Add 100 iron plates to your inventory
=== Remove all pollution ===
/c game.local_player.insert{name="iron-plate", count=100}


* Refill resources (refill oil, iron etc.)
/c local surface = game.player.surface;
While holding the cursor over a resource in-game
for coord in surface.get_chunks() do
/c game.local_player.selected.amount=7500
  surface.pollute({coord.x * 32, coord.y * 32}, -10000000)
end


* Add new resource patch
=== Add new resource patch ===
This creates a new 5x5 patch of resources, centered on the player character. For resources other than stone, just change "stone" to "iron-ore", "copper-ore", or "coal"
This creates a new 5x5 patch of resources, centered on the player character. For resources other than stone, just change "stone" to "iron-ore", "copper-ore", or "coal"


  /c local surface = game.local_player.surface;
  /c local surface = game.player.surface;
  for y=-2,2 do
  for y=-2,2 do
   for x=-2,2 do
   for x=-2,2 do
   surface.create_entity({name="stone", amount=5000, position={game.local_player.position.x+x, game.local_player.position.y+y}})
   surface.create_entity({name="stone", amount=5000, position={game.player.position.x+x, game.player.position.y+y}})
   end
   end
  end
  end


* Finish research
=== Add new oil patch ===
/c for name,technology in pairs(game.local_player.force.technologies) do technology.researched=technology.enabled end
This creates 9 crude oil patches in a 3x3 square.


* Mine faster
  /c for y=0,2 do
  /c game.local_player.force.manual_mining_speed_modifier=1000
  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


* Craft faster
or randomly without any collision:
/c game.local_player.force.manual_crafting_speed_modifier=1000


* [http://www.factorioforums.com/forum/viewtopic.php?f=5&t=9020 Switching on peacfulmode]
/c local position = nil
  /c game.peaceful_mode = true
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 ===
Ranges from 0 (new game) to 1.
 
/c game.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 and worms, spawners will not be killed.
  /c game.forces["enemy"].kill_all_units()
  /c game.forces["enemy"].kill_all_units()


* Faster research
=== Kill all enemies ===
  /c game.local_player.force.laboratory_speed_modifier = 1
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.
 
/c local surface = game.player.surface
for c in surface.get_chunks() do
    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
        entity.destroy()
    end
  end
 
=== Enable peaceful mode ===
Peaceful mode prevents biter attacks until provoked. Substitute false for true to disable.
/c game.player.surface.peaceful_mode = true
 
=== Disable biter expansion ===
This prevents biters from creating new spawners.
/c game.map_settings.enemy_expansion.enabled = false
 
== Player Character ==
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.
 
=== Spawn a player character ===
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.
 
/c game.player.character = game.player.surface.create_entity{name="player", position = {0,0}, force = game.forces.player}
 
=== Change Player color ===
Note that commands that do not start with "/c" do not disable achievements. Replace COLOR with the name of a color.
/color COLOR
 
=== 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
 
/c game.player.create_character()
 
== Research ==
=== Enable faster research ===
  /c game.player.force.laboratory_speed_modifier = 1
1 is normal speed, 2 is double speed 3 is triple etc. I think it goes up to 100.
1 is normal speed, 2 is double speed 3 is triple etc. I think it goes up to 100.


* [http://www.factorioforums.com/forum/viewtopic.php?f=18&t=5686 Destroy rocks in sandbox-mode] (you don't have a player here, so you can't destroy anything)
=== Enabling specific technologies ===
  /c for _,entity in pairs(game.local_player.surface.find_entities_filtered{
[http://www.factorioforums.com/forum/viewtopic.php?f=18&t=6633 Enabling technologies] (forums)
        area={{game.local_player.position.x-32, game.local_player.position.y-32},
/c game.player.force.technologies['electric-energy-distribution-1'].researched=true
            {game.local_player.position.x+32, game.local_player.position.y+32}},
/c game.player.force.technologies['steel-processing'].researched=true
            name="stone-rock"})
 
  do
=== Enabling specific recipes ===
    entity.destroy()
/c game.player.force.recipes["electric-energy-interface"].enabled = true
  end
/c game.player.force.recipes["rocket-silo"].enabled = true
you need to center the rock in your vision range
 
=== Finish research immediately ===
/c for name,technology in pairs(game.player.force.technologies) do technology.researched=technology.enabled end
 
== Command Line Parameters ==
'''As of Game Version 0.14.21'''


* [http://www.factorioforums.com/forum/viewtopic.php?f=41&t=5638 Use print() instead of game.local_player.print()]
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.
/c print = function(text) game.local_player.print(text) end


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


* [http://www.factorioforums.com/forum/viewtopic.php?f=14&t=4761&p=44184#p44184 Generate a section of the world and explore it at the same time]
Running options:
/c game.local_player.force.chart(game.local_player.surface,{lefttop = {x = -1024, y = -1024}, rightbottom = {x = 1024, y = 1024}})
  -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.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


Simply change the bounding box to the size you want and it will generate the map and explore it in that area. Keep In mind that command is telling Factorio to generate 64*64 (4096) chunks so it's going to take a while before all the background entity generation (trees, resources, biters) are placed in the world.
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


* [http://www.factorioforums.com/forum/viewtopic.php?f=5&t=6066&p=47758#p47758 Check water level in a pipe]
=== Multiplayer ===
/c game.local_player.print(game.local_player.selected.get_liquid().amount)


* [http://www.factorioforums.com/forum/viewtopic.php?f=18&t=6633 Enabling technologies]
  --start-server SAVE
/c game.local_player.force.technologies['electric-energy-distribution-1'].researched=true
/c game.local_player.force.technologies['steel-processing'].researched=true


* [http://www.factorioforums.com/forum/viewtopic.php?f=5&t=9028 Player color]
Will start a Headless (Dedicated) server, with no GUI.
/c game.local_player.color={g=50,b=200,r=200,a=.9}


* [http://www.factorioforums.com/forum/viewtopic.php?f=18&t=9867&p=78209#p78209 Where can I see how many Robots are in my network?]
  --mp-load-game SAVE
Count all '''active robots'''
/c game.local_player.print(game.local_player.force.get_entitycount("logistic-robot"))
/c game.local_player.print(game.local_player.force.get_entitycount("construction-robot"))


Count all '''active and inactive robots''' in the network, but misses the ones flying over gaps in coverage:
SAVE is the file name of the save file. For instance, for saves/MySave.zip: ./factorio --mp-load-game MySave.zip
This is no longer needed because the roboport will give accurate counts.
    /c robots = {};
    roboports = {};
    logistic = 0;
    construction = 0;
    recurse = function(r)
      id = r.position.x .. "," .. r.position.y;
      if (roboports[id] or r.force.name ~= game.player.force.name) then return end;
      roboports[id] = true;
      logistic = logistic + r.getinventory(1).getitemcount("logistic-robot");
      construction = construction + r.getinventory(1).getitemcount("construction-robot");
      ids = {};
      for _, robot in ipairs(game.findentitiesfiltered{area={{r.position.x-50, r.position.y-50}, {r.position.x+50, r.position.y+50}}, name="construction-robot"}) do;
          id = robot.position.x .. "," .. robot.position.y;
          if ((ids[id] or not robots[id]) and robot.force.name == game.player.force.name) then;
            construction = construction + 1;
            ids[id] = true;
            robots[id] = true;
          end;
      end;
      for _, robot in ipairs(game.findentitiesfiltered{area={{r.position.x-50, r.position.y-50}, {r.position.x+50, r.position.y+50}}, name="logistic-robot"}) do;
          id = robot.position.x .. "," .. robot.position.y;
          if ((ids[id] or not robots[id]) and robot.force.name == game.player.force.name) then;
            logistic = logistic + 1;
            ids[id] = true;
            robots[id] = true;
          end;
      end;
      for _, roboport in ipairs(game.findentitiesfiltered{area={{r.position.x-48.5, r.position.y-48.5}, {r.position.x+48.5, r.position.y+48.5}}, name="roboport"}) do;
          recurse(roboport);
      end;
    end;
    p = game.player.character.position;
    roboport = game.findentitiesfiltered{area={{p.x-48.5, p.y-48.5}, {p.x+48.5, p.y+48.5}}, name="roboport"}[1];
    if (roboport) then;
      recurse(roboport);
      game.player.print("Robots in network: Construction:" .. construction .. " Logistic:" .. logistic);
    else;
      game.player.print("Not in range of a roboport.");
    end


* [http://www.factorioforums.com/forum/viewtopic.php?f=34&t=10159 Disable evolution, increases pollution evolution instead]
  --mp-connect ADDRESS
/c game.mapsettings.enemy_evolution.time_factor = 0.000008 * 0
ADDRESS is the IP:port of the remote host. Port is optional.
/c game.mapsettings.enemy_evolution.pollution_factor = 0.00003 * 2
Examples:


* [http://www.factorioforums.com/forum/viewtopic.php?f=18&t=19447&p=124039#p123991 Custom Scenario: How to spawn a character at a certain point (instead of being in god-mode]
  ./factorio --mp-connect 192.168.1.101
/c game.local_player.character = game.local_player.surface.create_entity{name="player", position = {0,0}, force = game.forces.player}
  ./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.


More commands can be looked up in the [[Modding|modding-section]].
  --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.


== See also ==
== See also ==


* [http://www.factorioforums.com/forum/viewtopic.php?f=5&t=7981 Superspeedrun]
* http://lua-api.factorio.com/latest/ - Factorio API reference for latest version
* [http://www.factorioforums.com/forum/viewtopic.php?f=18&t=4752 The Console: What is it and How do I use it?]
* http://lua-api.factorio.com/ - links to specific versions of API reference
: Some interesting cheats or useful commands and tips.
[[Category:Console]]
* [http://www.factorioforums.com/forum/viewtopic.php?f=5&t=6942&p=543H57#p54357 Totaly new player -> setting up a game]:
# Preface all console commands with /c in .11.0+
# Set player to white
game.local_player.color = {g=1,b=1,r=1,a=.9}
# remove old player
game.remove_offline_player("username")
# Technology and Recipe unlocking
game.local_player.force.reset_technologies()
game.local_player.force.reset_recipes()
game.local_player.force.enable_all_technologies() # does not research them (see below)
game.local_player.force.enable_all_recipes()
game.local_player.force.research_all_technologies()
game.local_player.force.technologies["technology-name"].researched = true
# cheating
game.local_player.force.manual_mining_speed_modifier = 200
game.local_player.force.manual_crafting_speed_modifier = 200
game.speed = 2
game.freeze_day_time()
game.always_day = true
game.peaceful_mode = true
game.local_player.insert{name="item-name", count=1}

Revision as of 15:54, 11 February 2017


Overview

The in-game console is used for:

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

There are three types of command:

  • Multiplayer - message filtering, banning users, etc.
  • Information - display various information about the game
  • 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.

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. In Factorio 0.14.5 and later, you can clear the console 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).

In Factorio 0.14.5 and later, the Tab key will auto-complete commands and player ids.

Multiplayer Chat

Send private message to specific player with /whisper (or /w):

/whisper <playerId> <message>

Reply to the most recently received private message with /reply (or /r):

/reply <message>

In Factorio 0.14.4 and later, group chat works like this:

hello my team!
/s hello all players!
/shout same as /s

In Factorio 0.14.3 and earlier, group chat worked like this:

hello all players!
/team hello my team!

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.


Commands

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.

/help

In 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:

/h evolution

Scripting and cheat commands

You can run Lua script commands via the console. It works similarly to any command line interface or the JavaScript console for your browser.

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.

To run a script, prefix it with /command (or /c), for example:

/c game.player.print 'hello me!'

If you're in a multiplayer game, the command will be echoed to all other players (so they can see if you're cheating).

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

/silent-command game.player.print 'only admins can use (and see) silent commands'

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.

/measured-command game.player.print 'how much time does this take to run?'

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.

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.


Basic Command Examples

Large Screenshots

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

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.

/c game.take_screenshot{<parameters>}

The command takes the following parameters, separated by commas:

  • showgui - Boolean value, true or false. True if GUIs should be included in the screenshot.
  • resolution - Takes an x and y, in the form {x = XPOS, y = YPOS}
  • show_entity_info - Boolean value, true if alt info should be shown in the screenshot.
  • zoom - A value to take the screenshot from a certain zoom.

Use it as calculator

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

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 Technology

/c game.player.force.research_all_technologies()

Undo this with:

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

Reset any modifiers to default

This includes Tech and speed alterations.

/c game.player.force.reset()

Zoom beyond normal bounds

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

/c game.player.zoom = 0.1


Inventory Manipulation

Refill resources (refill oil, iron etc.)

While holding the cursor over a resource tile in-game

/c game.player.selected.amount=7500

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}

Cheat mode

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

/c game.player.cheat_mode=true


World Manipulation

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

Enables eternal day.

/c game.surfaces[1].always_day=true

Change game speed

0.5 is half speed, 1 is default, 2 is double speed, etc. 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 Passage

Stops the advancement of the time if true is passed, or unfreezes it if false is passed.

/c game.player.surface.freeze_daytime(BOOL)

Remove all pollution

/c local surface = game.player.surface;
for coord in surface.get_chunks() do
 surface.pollute({coord.x * 32, coord.y * 32}, -10000000)
end

Add new resource patch

This creates a new 5x5 patch of resources, centered on the player character. For resources other than stone, just change "stone" to "iron-ore", "copper-ore", or "coal"

/c local surface = game.player.surface;
for y=-2,2 do
 for x=-2,2 do
  surface.create_entity({name="stone", amount=5000, position={game.player.position.x+x, game.player.position.y+y}})
 end
end

Add new oil patch

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

/c for y=0,2 do
  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

Ranges from 0 (new game) to 1.

/c game.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 and worms, 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.

/c local surface = game.player.surface
for c in surface.get_chunks() do
   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
       entity.destroy()
   end
 end

Enable peaceful mode

Peaceful mode prevents biter attacks until provoked. Substitute false for true to disable.

/c game.player.surface.peaceful_mode = true

Disable biter expansion

This prevents biters from creating new spawners.

/c game.map_settings.enemy_expansion.enabled = false

Player Character

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.

Spawn a player character

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.

/c game.player.character = game.player.surface.create_entity{name="player", position = {0,0}, force = game.forces.player}

Change Player color

Note that commands that do not start with "/c" do not disable achievements. Replace COLOR with the name of a color.

/color COLOR

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

/c game.player.create_character()

Research

Enable faster research

/c game.player.force.laboratory_speed_modifier = 1

1 is normal speed, 2 is double speed 3 is triple etc. I think it goes up to 100.

Enabling specific technologies

Enabling technologies (forums)

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

Enabling specific recipes

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

Finish research immediately

/c for name,technology in pairs(game.player.force.technologies) do technology.researched=technology.enabled end

Command Line Parameters

As of Game Version 0.14.21

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

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

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

Multiplayer

 --start-server SAVE

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

 --mp-load-game SAVE

SAVE is the file name of the save file. For instance, for saves/MySave.zip: ./factorio --mp-load-game MySave.zip

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

See also