GDIW - Gah! DarnItWater!

Allows switching liquid recipe inputs and outputs.
3 days ago
0.13 - 0.17
33819

i Working icon-search

- 2 years ago
(updated 2 years ago)

I have a suggestion for the automatic icon search for the newly generated recipes, shown below (and probably mangled beyond readability by the forum software).

In the case that no recipe-specific icon is present, instead of relying on the first entry in the results list, why not iterate over the full list, until an icon is found or the list is exhausted? Additionally, the simple string notation of a single result can be rolled up into this method:

<pre>newicons = {} --grab old icon(s) if vro.icon then table.insert(newicons,{icon=vro.icon}) elseif vro.icons then newicons = util.table.deepcopy(vro.icons) else -- Look through results for an icon local resultList = {} if vrn.results then -- Do we have a list of results? resultList = vrn.results -- Use it as-is elseif vrn.result then -- Is there a single result string? -- Check the raw table for an object of the given name and fake a sparse result object if data.raw.item[vrn.result] then table.insert(resultList, {type="item", name=vrn.result}) elseif data.raw.fluid[vrn.result] then table.insert(resultList, {type="fluid", name=vrn.result}) end end -- Now iterate over the list of results, until we either find an icon or checked all. for _, result in pairs(resultList) do if result.type == "item" or result.type == "fluid" then local rawResult = data.raw[result.type][result.name] if rawResult.icon then table.insert(newicons,{icon=rawResult.icon}) elseif rawResult.icons then newicons = util.table.deepcopy(rawResult.icons) end if #newicons > 0 then break end end end end if #newicons == 0 then table.insert(newicons,{icon="__GDIW__/graphics/placeholder.png"}) end </pre>

This method works very well for me. It finally gives a proper icon to the alternative sulfur recipe in Bob's Plates, which previously only got the default placeholder.