Code: Select all
local areaList = builder.surface.find_entities_filtered{position = pos, radius = builder.reach_distance, type = {"entity-ghost", "tile-ghost"}, force=builder.force, limit=200 }
But if I change that to
Code: Select all
local areaList = builder.surface.find_entities_filtered{type = {"entity-ghost", "tile-ghost"}, force=builder.force, limit=200 }
It looks like find_entitites_filtered with an area to search iterates over the whole area while searching the whole surface only goes through the generated chunks. This problem could be avoided by checking the radius against the number of generated chunks on the surface and picking a smarter iterator:
Code: Select all
if (M_PI * radius * radius > surface.num_generated_chunks) {
iterate_over_generated_chunks(...);
else
iterate_over_area(...);
end
PS: same problem probably exists when searching for tiles, when counting entities/tiles, find_non_colliding_position, ...