It would be good to search tiles with some fast function. For example we have
Code: Select all
surface.count_entities_filtered{area=…, position=…, name=…, type=…, force=…, limit=…}
Code: Select all
surface.count_entities_filtered{area=area, force=player_force, limit=1}
Code: Select all
function find_first_good_tile_in_chunk(chunk, surface, good_tiles_list)
for y = (chunk.y*32), (chunk.y*32+31) do
for x = (chunk.x*32), (chunk.x*32+31) do
local tile = surface.get_tile(x, y)
for i, tile_name in pairs (good_tiles_list) do
if tile and (tile.name == tile_name) then
return true
end
end
end
end
return false
end
Performance was got from https://mods.factorio.com/mods/darkfrei ... sion/21503 - first tile searching needs twice (in this case) more time then first entity searching with force in higher quantity of chunks.