[Solved]Can not delete unused chunks
Posted: Sat Aug 11, 2018 10:15 am
Hi, i wrote this code, which should delete all the chunks except those on which there are player builds.But instead, he removes the chunks on the contrary with the players buildings. Why?
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