Set Custom Circuit Condition for Inserters in Filter Mode
Posted: Thu Jul 21, 2016 8:28 pm
Abstract: Allow filter inserters to be configured to filter for negative signals (or any other condition than the default positive).
At the moment, when filter inserters are connected to the circuit network and set to "set filters" mode, they will grab any item for which they receive a positive signal from the network. I would like to be able to change the condition from "positive" to other conditions of the form > x or < x or = x where x is a number (or signal). That is, to allow filters to work analogously to decider combinators working on a condition involving "each". Of particular use to me would be to allow them to filter for only the items with a negative signal.
This would be particularly useful when one uses filter inserters which are both setting their filters from the circuit network and (in some mode) sending their contents to the circuit network. It would allow these signals to be "opposed" to each other so that the pulse from the filter picking up an item could trigger the item to be taken out of the filter the next tick. I already use this principle with belts - for instance, in the image below, the first belt is activated when (stone) < 11 and the second belt is in pulse mode, the combinator is set to +0 and the constant combinator is set to -11 stone. It works so that the moment the second belt signals that it has received enough stone, the first belt is shut off. I would love to be able to set a filter inserter to filter for negative items to allow the following setup to filter for exactly 11 stone (where the filter inserter is in "pulse" mode for reading): However, at the moment, this cannot be done since filter inserters are locked to filtering for positive signals. In any setup, this requires some additional logic to remove the filter, so requires both an extra tick (at least) to respond to the stimulus, and more combinators. With this "negative means go" convention, I do not need to build any new combinators to control new belts - it's easy enough to build a central system which counts all pulses sent to it (with no delay) and maintains the signal as that count minus some constants, thus controlling every belt attached to a single network.
As far as I can tell**, with filter inserters as they currently are, it is impossible to build a system with the same nice properties as the belt control system I use - each inserter needs at least one combinator to control it/read its output. Further, a filter cannot fail its circuit network condition the moment the inserter sends out the appropriate pulse, since the combinators take time to process. The best system I've come up with for the current behavior is two ticks slower* than what I propose and uses one extra combinator per filter inserter.
This is similar to existing functionality in both decider combinators and the usual enabled/disabled GUI, so I doubt it would be too hard to implement. However, it would make building large smart factories substantially easier by allowing filter inserters to easily be set up to grab exact amounts of items.
(*This is enough of a delay to cause a filter inserter with stack bonus to retrieve too many items off a red belt. It can handle a yellow belt fine though. I'd assume that one could get the delay down by a tick with some circuit network witchcraft, but I'll bet that blue belts would still be troublesome)
(**EDIT: It has occurred to me that one can abuse integer overflow to get things to work. I'd generally prefer such behaviors not to be necessary to reasonably straightforwards application, though)
At the moment, when filter inserters are connected to the circuit network and set to "set filters" mode, they will grab any item for which they receive a positive signal from the network. I would like to be able to change the condition from "positive" to other conditions of the form > x or < x or = x where x is a number (or signal). That is, to allow filters to work analogously to decider combinators working on a condition involving "each". Of particular use to me would be to allow them to filter for only the items with a negative signal.
This would be particularly useful when one uses filter inserters which are both setting their filters from the circuit network and (in some mode) sending their contents to the circuit network. It would allow these signals to be "opposed" to each other so that the pulse from the filter picking up an item could trigger the item to be taken out of the filter the next tick. I already use this principle with belts - for instance, in the image below, the first belt is activated when (stone) < 11 and the second belt is in pulse mode, the combinator is set to +0 and the constant combinator is set to -11 stone. It works so that the moment the second belt signals that it has received enough stone, the first belt is shut off. I would love to be able to set a filter inserter to filter for negative items to allow the following setup to filter for exactly 11 stone (where the filter inserter is in "pulse" mode for reading): However, at the moment, this cannot be done since filter inserters are locked to filtering for positive signals. In any setup, this requires some additional logic to remove the filter, so requires both an extra tick (at least) to respond to the stimulus, and more combinators. With this "negative means go" convention, I do not need to build any new combinators to control new belts - it's easy enough to build a central system which counts all pulses sent to it (with no delay) and maintains the signal as that count minus some constants, thus controlling every belt attached to a single network.
As far as I can tell**, with filter inserters as they currently are, it is impossible to build a system with the same nice properties as the belt control system I use - each inserter needs at least one combinator to control it/read its output. Further, a filter cannot fail its circuit network condition the moment the inserter sends out the appropriate pulse, since the combinators take time to process. The best system I've come up with for the current behavior is two ticks slower* than what I propose and uses one extra combinator per filter inserter.
This is similar to existing functionality in both decider combinators and the usual enabled/disabled GUI, so I doubt it would be too hard to implement. However, it would make building large smart factories substantially easier by allowing filter inserters to easily be set up to grab exact amounts of items.
(*This is enough of a delay to cause a filter inserter with stack bonus to retrieve too many items off a red belt. It can handle a yellow belt fine though. I'd assume that one could get the delay down by a tick with some circuit network witchcraft, but I'll bet that blue belts would still be troublesome)
(**EDIT: It has occurred to me that one can abuse integer overflow to get things to work. I'd generally prefer such behaviors not to be necessary to reasonably straightforwards application, though)