Last active
November 4, 2015 03:37
-
-
Save Afforess/9918bca49dd6a863fb03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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