Skip to content

Instantly share code, notes, and snippets.

@Afforess
Last active November 4, 2015 03:37
Show Gist options
  • Save Afforess/9918bca49dd6a863fb03 to your computer and use it in GitHub Desktop.
Save Afforess/9918bca49dd6a863fb03 to your computer and use it in GitHub Desktop.
function find_all_entity(entity_name)
local surface = game.surfaces['nauvis']
local entities = {}
for chunk in surface.get_chunks() do
local chunk_area = {lefttop = {x = chunk.x*32, y = chunk.y*32}, rightbottom = {x = chunk.x*32+32, y = chunk.y*32+32}}
local chunk_entities = surface.find_entities_filtered({area = chunk_area, name = entity_name})
for i = 1, #chunk_entities do
entities[#entities + 1] = chunk_entities[i]
end
end
return entities
end
print(serpent.dump(find_all_entity('mining-drill')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment