Skip to content

Instantly share code, notes, and snippets.

@justarandomgeek
Last active July 16, 2023 06:43
Show Gist options
  • Save justarandomgeek/19b7844831087df40890229e7e92768d to your computer and use it in GitHub Desktop.
Save justarandomgeek/19b7844831087df40890229e7e92768d to your computer and use it in GitHub Desktop.
Factorio Commands
/c for k,v in pairs(game.player.cursor_stack.cost_to_build) do
game.player.print(k .. ": " .. v)
end
/c
for _,p in pairs(game.players) do
p.opened=nil
p.opened_gui_type=nil
end
/c game.players[1].surface.create_entity{name = "biter-spawner", position = {game.players[1].position.x+10,game.players[1].position.y+10}}
-- Useful for adding aliens to a world that started without any
-- add this at the end of control.lua inside a save for extra commands
commands.add_command("teleport", "teleports to a position near the selected entity", function(e)
local player = game.players[e.player_index]
local sel = player.selected
if sel and player.character then
player.teleport(player.surface.find_non_colliding_position(player.character.prototype.name, sel.position, 0, 0.25),player.surface)
end
end)
commands.add_command("sudo", "silently runs commands, without disabling acheivements", function(e)
local player = game.players[e.player_index]
local func = loadstring(e.parameter)
local status,err = pcall(func)
if status then
else
player.print("Error running command: " .. err)
end
end)
/c for _,item in pairs(game.player.surface.find_entities_filtered{name='item-on-ground'}) do if item.stack.name=='alien-artifact' then item.destroy() end end
/c print=game.player.cursor_stack;
ents = print.get_blueprint_entities()
for i,ent in pairs(ents) do
if ent.connections then
for j,conn in pairs(ent.connections) do
local temp = conn.red
conn.red = conn.green
conn.green = temp
end
end
end
print.set_blueprint_entities(ents)
-- This will flip the wire colors of a print held in the players hand
/c for _,ent in pairs(game.player.surface.find_entities_filtered{name='rocket-silo'}) do game.player.print("X:" .. ent.position.x .. " Y:" .. ent.position.y) end
/c for _, entity in ipairs(game.player.surface.find_entities_filtered{ area={{game.player.position.x-10, game.player.position.y-10}, {game.player.position.x+10, game.player.position.y+10}}}) do game.print(entity.name) end
/c
local surface=game.player.surface
local basepos=game.player.position
local size=64
local tiles={}
for x=-size,size do
for y=-size,size do
local prevtile = surface.get_tile(basepos.x+x,basepos.y+y)
if prevtile.name == "concrete" and prevtile.hidden_tile then
table.insert(tiles,{name=prevtile.hidden_tile,position={basepos.x+x,basepos.y+y}})
end
end
end
surface.set_tiles(tiles)
/c print=game.player.cursor_stack;
ents = print.get_blueprint_entities()
for i,ent in pairs(ents) do
if ent.name="express-belt" then
ent.name="fast-belt"
end
end
print.set_blueprint_entities(ents)
/c print=game.player.cursor_stack;
local offset = {x=10, y=10)
ents = print.get_blueprint_entities()
for i,ent in pairs(ents) do
ent.position.x = ent.position.x + offset.x
ent.position.y = ent.position.y + offset.y
end
print.set_blueprint_entities(ents)
tiles = print.get_blueprint_tiles()
for i,ent in pairs(tiles) do
tiles.position.x = tiles.position.x + offset.x
tiles.position.y = tiles.position.y + offset.y
end
print.set_blueprint_tiles(tiles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment