Skip to content

Conversation

@Lynnatic
Copy link
Contributor

Hi there, i am currently trying to pitch in into the efforts to make recipe signals/icons easier to differentiate (as mentioned in pyanodon/pybugreports#1193).

I picked the atomizer recipes since they seemed a good starting point (all centralized in a file, not too many recipes) but ran into problems with py.composite_icon crashing when trying to use pyalienlife's plants. I fixed the problem and made the function a bit more robust in the process, faster too in a separate commit, both of which are in this pull request.

I hope it's okay to open pull requests like that, i'm not sure if you want to see a topic in pybugreports first.

Also: I have a couple of ideas on how to make a possibly somewhat easier to use (counting nil arguments is not fun) and perhaps more powerful composite icon generator, would you be interested in something like that? I really don't want to step on any toes nor spend my time with something that nobody is interested in in the end ;b

pyalienlife's plants and creatures are currently created as modules
instead of items. This causes py.composite_icon to fail, as it only
searches for fluids/items/recipes and not for modules.
The modules also specify "icons" instead of "icon", which causes
another problem when trying to use py.composite_icon with them.

This patch solves these problems by:
* Reworking the way icons are searched.
* Adding "modules" to the list of datasets that is searched for icons.
* Allow the "icons" field to be used (the first icon in the array is
  automatically selected in this case)

Additional changes:
* Only use a prototype match if it has an "icon" or "icons" field present.
* Throw a specific "No icon found for prototype X" error message when
  no icon could be found in any of the datasets - Which is a lot easier
  to understand than a rather cryptic "trying to access nil value" error.

Notes:
* This patch changes only the internal workings of py.composite_icon,
  generated icons will look the same as before.
* "modules" have been deliberately added after "recipes" to the search list;
  While it would make more sense to search "modules" first, doing so might
  make already existing icons look different, which we want to avoid here.
Currently the fluid/item/recipe/module datasets are searched
two times for each corner icon, once for the icon shadow, once for the icon.
This is rather inefficient since the icon shadow and the icon are using
exactly the same .png image, so both can be added by using only one search.

This patch fixes this problem by regrouping the corner icon code;
From "all corner icon shadows, then all corner icons" to
"icon shadow, then icon" for each of the four corners.

Note: Internal changes only, generated icons will look the same as before.
@notnotmelon notnotmelon merged commit bba1152 into pyanodon:main Sep 15, 2025
17 checks passed
@notnotmelon
Copy link
Contributor

Amazing PR, thanks so much.
More powerful composite icons generator would be awesome to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants