Skip to content

Instantly share code, notes, and snippets.

@kurtzilla
Forked from morsk/remove_rocks_on_map.lua
Created October 24, 2024 04:14
Show Gist options
  • Save kurtzilla/eb3c6088d838e18df20c55b275a4fa7c to your computer and use it in GitHub Desktop.
Save kurtzilla/eb3c6088d838e18df20c55b275a4fa7c to your computer and use it in GitHub Desktop.
remove rocks on map [Factorio]
/c --[[ remove rocks ]]
local function count_in(t, s)
t[s] = (t[s] or 0) + 1
end
local counts = {}
for _,e in pairs(game.player.surface.find_entities_filtered{type = {"simple-entity"}}) do
--[[ starts rock- , has -rock- in middle, or ends -rock ]]
if e.name:match("^rock%-") or e.name:match("%-rock%-") or e.name:match("%-rock$") then
count_in(counts, e.name)
e.destroy()
end
end
game.print("removed rocks:")
for name,count in pairs(counts) do
game.print(" "..name..": "..count)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment