Closed fabi321 closed 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.
The signals module now has a couple of changes to it:
signals.raw
is now more in line with the other raw
data structures; you can query a specific signal and get all relevant information about that underlying item/fluid/signal:
print(signals.raw["iron-ore"])
# {'order': 'e[iron-ore]', 'icon_size': 64, 'name': 'iron-ore', ... }
signals.raw
is an OrderedDict
though and is already sorted according to Factorio's sort order, so no extra work should be required:
for signal_name in signals.raw:
print(signal_name)
# "wooden-chest"
# "iron-chest"
# "steel-chest"
# ...
signals.raw
is moved to a new structure, signals.type_of
, which allows you to quickly query the signal type (might differ to signals.raw[name]["type"]
):
print(signals.type_of["assembling-machine-1"]) # "item"
print(signals.type_of["lubricant"]) # "fluid"
print(signals.type_of["signal-everything"]) # "virtual"
In addition, signals.pure_virtual
was added to allow for easy inclusion/exclusion when desired:
for virtual_signal in signals.virtual:
if virtual_signal in signals.pure_virtual:
continue # skips "signal-everything", "signal-anything", and "signal-each"
# Else, do whatever with the normal signal
These changes will be in version 0.9.6
.
I like the way how these changes are implemented. However, from my ingame testing, the order is virtual
then fluid
and finally item
.
from my ingame testing, the order is
virtual
thenfluid
and finallyitem
.
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.
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.
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.
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.