DaCyclops / GDIW

Factorio Mod : GDIW - Gah!DarnItWater! A Factorio mod for those people who keep getting annoyed at water....
MIT License
3 stars 5 forks source link

Handle shorthand "result" while looking for icon #10

Closed JustTheBast closed 7 years ago

JustTheBast commented 7 years ago

When looking for an icon to represent a recipe, check all items in the results list, not just the first, until an icon is found or the list runs out. To avoid repetition, of the same code when dealing with shorthand results, check the raw data table for a matching item or fluid, then fake a one-item results list that can run through the same loop. Since the search of the results is not guaranteed to yield an icon, setting the default icon is no longer in an "ifelse" branch that only runs if no results exist, but is an independent if-clause that checks whether any of the preceding attempts succeeded.

DaCyclops commented 7 years ago

Yeah, that actually seems to be fairly well done, and covers all the bases I was hoping to when I had time.

And yes ,the place holder default works MUCH better that way.... I was already panicking about how to handle it in worst-case scenarios.

Thanks for the code. I think this can go in and be tested....