Console
This article is a stub, and not comprehensive. |
---|
You can help this wiki by expanding it. |
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.
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.
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.
How to open the console?
You open the console by default with the key '/' or '~'. This is the chat window in multiplayer! The prefix for Lua commands is '/c'.
To change that key go into the keyboard control and change "Toggle Lua console" to a useful key.
Change in v0.11
You need to type '/c' in front of your commands. Otherwise it is just a chat message.
Editing
The console has an inbuilt history. You can use the "cursor-up"-key to edit/repeat the previous commands.
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.
Useful commands (cheats)
The 0.12.x updated added a _ to a the majority of the methods and properties.
- Remove all enemies from the map
/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!)
/c game.local_player.print(1234 * 5678)
- Check how far the biters have evolved
/c game.local_player.print(game.evolution_factor)
- Turn off night
/c game.always_day=true
- Zoom out to place blueprints, that are bigger than your screen.
/c game.local_player.zoom = 0.1
- Kill all biters on the "enemy" force
/c game.forces["enemy"].kill_all_units()
- Add 100 iron plates to your inventory
/c game.local_player.insert{name="iron-plate", count=100}
- Refill resources (refill oil, iron etc.)
While holding the cursor over a resource in-game
/c game.local_player.selected.amount=7500
- 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.local_player.surface; for y=-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}}) end end
- Finish research
/c for name,technology in pairs(game.local_player.force.technologies) do technology.researched=technology.enabled end
- Mine faster
/c game.local_player.force.manual_mining_speed_modifier=1000
- Craft faster
/c game.local_player.force.manual_crafting_speed_modifier=1000
/c game.peaceful_mode = true /c game.forces["enemy"].kill_all_units()
- Faster research
/c game.local_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.
- Destroy rocks in sandbox-mode (you don't have a player here, so you can't destroy anything)
/c for _,entity in pairs(game.local_player.surface.find_entities_filtered{ area={{game.local_player.position.x-32, game.local_player.position.y-32}, {game.local_player.position.x+32, game.local_player.position.y+32}}, name="stone-rock"}) do entity.destroy() end
you need to center the rock in your vision range
/c print = function(text) game.local_player.print(text) end
/c game.local_player.force.chart(game.local_player.surface,{lefttop = {x = -1024, y = -1024}, rightbottom = {x = 1024, y = 1024}})
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.
/c game.local_player.print(game.local_player.selected.get_liquid().amount)
/c game.local_player.force.technologies['electric-energy-distribution-1'].researched=true /c game.local_player.force.technologies['steel-processing'].researched=true
/c game.local_player.color={g=50,b=200,r=200,a=.9}
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: 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
/c game.mapsettings.enemy_evolution.time_factor = 0.000008 * 0 /c game.mapsettings.enemy_evolution.pollution_factor = 0.00003 * 2
/c game.local_player.character = game.local_player.surface.create_entity{name="player", position = {0,0}, force = game.forces.player}
More commands can be looked up in the modding-section.
See also
- Some interesting cheats or useful commands and tips.
# 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}