Code: Select all
function delete_chunks()
local surface = game.surfaces.nauvis
for chunk in surface.get_chunks() do
local entities = surface.find_entities_filtered{area={{chunk.x*32, chunk.y*32}, {(chunk.x)*32+32, (chunk.y)*32+32}},force = "player"}
for _, entity in pairs(entities) do
if #entity == 0 then
surface.delete_chunk({chunk.x,chunk.y})
end
end
end
end