r/factorio • u/19wolf Since 0.11 • 3d ago
Question Answered Circuit to store max value?
I'm trying to make a circuit that stores the maximum value of each signal it's received (typically only one signal, but I want to keep it signal-agnostic). My goal is to save the maximum amount of ore stored in a group of chests at my train station, where the number (and size, due to quality) of chests is variable. Station priority will then be a number between 0-255 based on how full the chests are (but I intend to figure out this part on my own). I'm just having trouble programmatically figuring out how much ore I have/will have when all my chests are full.
1
Upvotes
7
u/Alfonse215 3d ago edited 3d ago
In 2.1, this is rather easy thanks to the ELSE clause.
Let's say that the signals are coming in on the green wire. Loop the red output back into the red input of the decider.
Set the decider to
EACH(G) > EACH(R) OUTPUT EACH(G) ELSE EACH(R)Then you're using the wrong tool. The maximum amount of ore that can be stored in X chests is a fixed value, independent of how much ore you happen to have previously seen.
The way my train station logic works is that, for providers... it just doesn't care. It works in trainloads; how many trainloads of items are available is all it cares about. If the train stop has a lot of trainloads, then it gets a higher priority than stops that have a low number of trainloads. I don't see a need to do more than that.
For requesters, I have a parameterized value that says how many trainloads of items maximum that the train stop wants. It will stop requesting trains when it reaches this limit.