There's probably a very simple answer, but it's driving me crazy. How do I set a signal value to a maximum if it is above the maximum, but otherwise leave it alone?
If I use a decider combinator with "less than or equal" it will output the value if it is equal to or below the maximum, but if the value is above the max, it will output nothing, not the maximum I want.
If I add a second, parallel combinator with "greater than", I can't have it output the maximum because a decider can only output the incoming value (which is above the maximum) or 1.
If I use a different signal (such as a gray color signal when I'm trying to cap the iron ore signal) with a constant combinator for the maximum, then a decider can be set to output the "input count" of that different signal if the one I'm trying to cap is higher. And then I will need to somehow swap it back to having that value on the original channel.
With all the improvements that were made to circuits/combinators in 2.0 (or even ones before that I missed) there's got to be a way to set a maximum value without using 3-5 different combinators.
Simple way to cap a circuit signal at a maximum value?
- Mad Inventor
- Burner Inserter
- Posts: 11
- Joined: Sun Mar 13, 2016 1:10 am
- Contact:
-
- Manual Inserter
- Posts: 1
- Joined: Sat Nov 09, 2024 10:09 pm
- Contact:
Re: Simple way to cap a circuit signal at a maximum value?
Hi! I have thought a little about it and can't find a clever way to do it. A naive way is to use two deciders and an arithmethic combinator:
- First decider reads input signal, if less than max, output that signal.
- Second decider reads input signal, if greater or equal to max, output 1 of that signal. Output of that connects to input of arithmetic combinator, which multiplies the value by the max and outputs it.
- Join the outputs of first decider and the arithmetic combinator and you will have the input value capped at max.
Re: Simple way to cap a circuit signal at a maximum value?
Use a constant combinator to feed in the maximum value, then have two deciders one for less than the maximum which outputs the original item count, the other for greater or equal to the maximum which outputs the maximum input.
Re: Simple way to cap a circuit signal at a maximum value?
That also needs a translation to a help signal and a delay to keep synchronous., bringing it up to 5 combinators.
This setup does it with 4 You can set the maximum per constant combinator feeding a virtual signal in, making setting it up and using it multiple times easier, but then you need a decoupler on the input to prevent side effects, so since I don't know your requirements I left that off.
This setup does it with 4 You can set the maximum per constant combinator feeding a virtual signal in, making setting it up and using it multiple times easier, but then you need a decoupler on the input to prevent side effects, so since I don't know your requirements I left that off.
Re: Simple way to cap a circuit signal at a maximum value?
The OP got very close to the solution. Instead of putting the maximum directly into the deciders, put it into a constant combinator connected to both deciders, using the other wire color.
Decider 1: Each red <= Each green, output Each red
Decider 2: Each red > Each green, output Each green
You can replace Each with the actual signal you're interested in if you don't want nor need the vectorized version.
Decider 1: Each red <= Each green, output Each red
Decider 2: Each red > Each green, output Each green
You can replace Each with the actual signal you're interested in if you don't want nor need the vectorized version.
Re: Simple way to cap a circuit signal at a maximum value?
If I'm interessed in capping a single signal, I just found a simply method
connected to a selector combinator outputting first signal ordered ascending (so minimum value)
plus a convertor to go back to my signal
Please note that both my solution and the previous blueprint work only if the signal you want to cap is > 0; in case of signal = 0, in both cases max will be returned
edit: an improved version that works even when no input signal is provided.
connect input signal here
constant combinator with "up arrow" as maximum value (in this case DOT signal is for demo purpose, the signal I want to cap)connected to a selector combinator outputting first signal ordered ascending (so minimum value)
plus a convertor to go back to my signal
Please note that both my solution and the previous blueprint work only if the signal you want to cap is > 0; in case of signal = 0, in both cases max will be returned
edit: an improved version that works even when no input signal is provided.
connect input signal here