I was charting a lot of chunks awhile testing my mod, and in each chunk in some areas of the map, I call entity.destroy() on any enemy entites found.
Was mostly working fine, until it crashed.
Code: Select all
---@param surface LuaSurface
---@param area BoundingBox
---@return nil
function RemoveEnemiesInArea(surface, area)
for _, entity in pairs(surface.find_entities_filtered { area = area, force = "enemy" }) do
entity.destroy()
end
end