Page 1 of 1

Resource Patches Mouse Over Details

Posted: Thu Jun 08, 2017 8:59 pm
by AlienX
Hi All,
When you mouse over a resource in the map view, it shows you what type of resource it is, and how much is left.
Is this data accessible anywhere in the API - I cant seem to find anything useful towards it in the API Docs.

I'm thinking something like:

Code: Select all

for _,resource in pairs(game.surface["blah"].get_resource_piles()) do
  resource.type = "iron-ore" (Read Only)
  resource.amount = "320000" (Read Only)
  resource.area = {x,y} (Read Only)
end
 

Thanks

Re: Resource Patches Mouse Over Details

Posted: Thu Jun 08, 2017 9:34 pm
by Pandemoneus
No, it's not in the API.
However, since I tackled the same problem recently, I have implemented my own search that is now part of the modder's StdLib. If you can get the position of an ore, the function returns a list with all connected resources that you can iterate over and sum up the resource count.

Re: Resource Patches Mouse Over Details

Posted: Thu Jun 08, 2017 9:45 pm
by AlienX
Love you :D

On another note:
@Devs - Could this be included as an internal API to call - I feel it would be useful knowing exactly what the map thinks is there.