Page 1 of 1

PSA: Console commands to destroy resource patches, stone roc

Posted: Thu Nov 03, 2016 8:05 am
by Jackalope_Gaming
Crossposting this to Reddit as well at https://www.reddit.com/r/factorio/comme ... e_patches/


If you would like to destroy all ore-type patches and crude oil in an area around your character, use this command line:

Code: Select all

/c for _, entity in ipairs(game.player.surface.find_entities_filtered{ area={{game.player.position.x-32, game.player.position.y-32}, {game.player.position.x+32, game.player.position.y+32}}, type="resource"}) do entity.destroy() end
If you want to destroy stone rocks, use:

Code: Select all

/c for _, entity in ipairs(game.player.surface.find_entities_filtered{ area={{game.player.position.x-32, game.player.position.y-32}, {game.player.position.x+32, game.player.position.y+32}}, name="stone-rock"}) do entity.destroy() end
Replace "stone rock" with any of: "stone" "coal" "copper-ore" "iron ore" "crude-oil" to delete that respective resource. This also works on modded resources such as "rich-iron-ore" in Hardcrafting or "tin-ore" in Bob's Mods.
And if you want to delete trees, use this line:

Code: Select all

/c for _, entity in ipairs(game.player.surface.find_entities_filtered{ area={{game.player.position.x-32, game.player.position.y-32}, {game.player.position.x+32, game.player.position.y+32}}, type="tree"}) do entity.destroy() end
The 32's in each of the above lines measure distance away from your player character. If you wanted to only clear 4 spaces away from you then just replace the 32's with 4's and you're good to go.
If you want to delete all the resources in the entire discovered map, use this command line:

Code: Select all

/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}}, type= "resource"})) do entity.destroy() end end
If you want to delete all trees in the discovered area, use:

Code: Select all

/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}}, type= "tree"})) do entity.destroy() end end
And if you want to delete all stone rocks in the discovered area, use:

Code: Select all

/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}}, name= "stone-rock"})) do entity.destroy() end end
*Edited to fix the last command.

These commands only work in single player. Multiplayer will require a slight tweak where instead of game.player it's game.players[1] if you're player 1, game.players[2] if you're player 2, and so on.