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

Factorio-safety errors for circuit components #13

Closed fabi321 closed 2 years ago

fabi321 commented 2 years ago

Logic components like the arithmetic combinator and the decider combinator only accept a certain combination of special signals (e.g. signal-each, signal-anything and signal-everything). If they are set wrong, it doesn't even import a string.

The allowed combinations of these signals is explained here for decider combinators, and arithmetic combinators only allow one each as input, and only allow an each as output if it has each as input.

consider the following

d = DeciderCombinator()
d.set_decider_conditions('signal-everything', '<', 1, 'signal-each') # not allowed
bp=Blueprint()
bp.entities.append(d)
bp.to_string() # -> 0eNp9kE1uhDAMhe/idWY0jKC0UW8yqlAAd7BEfpQ4qAjl7jWURRdVl35+/p7tDfo5Y4jkGPQGxGhB/9IULBgTeQf6/lrV7du9bZq6btoXBeiYmDCBfmzgjEWZHHGgEeNl8LYnZ9hHQQSfxLgzNvgCfbs2ClbQ1fVWFAzecfRz1+NkFhK/mE5KJ73xmEy7+kkxcZfo6cy812fkj3BBWXTlidxTEnkNe2uhyFnMR4wNJh4LaXiHIzex2c+uFPjMIf/DNsP0B7WU8wlr57LtUdBV+SjlG/FxdTg=

The generated blueprint fails to import in Factorio, but no warning has been raised.

redruin1 commented 2 years ago

Good catch. I've changed the functionality of ArithmeticCombinator and DeciderCombinator to the following logic to match the game:

Value of first_operand Acceptable values for output_signal
All normal signals All normal signals, "signal-everything"
"signal-everything" All normal signals, "signal-everything"
"signal-anything" All normal signals, "signal-everything", "signal-anything"
"signal-each" All normal signals, "signal-each"

Note that "All normal signals" in this context also includes None, or no signal in these places. I've updated the docs as well to reflect these changes and document these special signals. This will be in version 0.9.5.

fabi321 commented 2 years ago

I just wanted to correct your truth table, as it is not in line with what the wiki says, but after testing ingame, I realized, that the wiki is wrong. Heads up for actually checking it ingame.