redruin1 / factorio-draftsman

A complete, well-tested, and up-to-date module to manipulate Factorio blueprint strings. Compatible with mods.
MIT License
94 stars 17 forks source link

Add some way to get either ordered signals, or expose the order property #17

Closed fabi321 closed 2 years ago

fabi321 commented 2 years ago

In order to deterministically emulate circuit networks, I need to know the order of all signals. Following this thread, they are ordered by their order tag first, and by their name afterwards. The order tag is supplied in the raw data, as can be seen here.

redruin1 commented 2 years ago

Funny, I thought this was sorted already. signals.item, signals.fluid, and signals.virtual are all sorted via that order, but they can't be easily recombined, which is unfortunate. I'll get to this when I wake up tomorrow.

redruin1 commented 2 years ago

The signals module now has a couple of changes to it:

fabi321 commented 2 years ago

I like the way how these changes are implemented. However, from my ingame testing, the order is virtual then fluid and finally item.

redruin1 commented 2 years ago

from my ingame testing, the order is virtual then fluid and finally item.

I assume you're referring to the order in which circuit signals are updated? The sort order which Draftsman defaults to follows the visual contents of the item menu, sorting by item group, item subgroup, and then finally the item itself. Also, if that was the desired sorted order, then could you not have done:

sort_order = signals.virtual + signals.fluid + signals.item
for signal_name in sort_order:
    # ...?

Or is there extra information in the raw data that you're hoping to access? I'll keep the changes regardless, just trying to understand your problem a little more.

fabi321 commented 2 years ago

This is not only the order how signals are processed, but also the order how they are displayed, i.e. on a power pole with signals. I thought that it might make sense to adopt the official sorting order, as there is one.

redruin1 commented 2 years ago

I see what you're saying now. The sort order signals.virtual + signals.fluid + signals.item seems to apply for mods as well based on prototype category, not on item sort order, so after consideration I support this change. Because it works on prototype category however, you can simply combine the three lists above in that order and you will get your correct order regardless of mods or otherwise, if you want a quick fix before version 0.9.6. I'll update the documentation as well.