Page 1 of 1

Compare two values of the same item

Posted: Sat Apr 29, 2017 11:34 am
by PitaPit
Big hello too all the Engineers

I have two chestws with iron.
Chest one contains 100 iron.
Chest two contains 50 iron.

I woud like to compare the amount of iron in the two chests with a decider combinator.
Unfortuantely the decider combinator adds up the two values to a total of 150 iron regardless of the colour of the input signals.

Is there a way to change the iron value of chest one into another item?
Or any other simple way to compare those two values?

Thank you for reading & im looking forward to hear your thoughts.

Re: Compare two values of the same item

Posted: Sat Apr 29, 2017 12:00 pm
by steinio
Hi,

you can use an arithmetic combinator to make iron * 1 output A and the other output B.
You'll find the letters in the signal tab (looks like a green electronic board).

Greetings, steinio.

Re: Compare two values of the same item

Posted: Sat Apr 29, 2017 12:07 pm
by PSS
Hello.
Before sending signal from one of the chests to decider combinator, you can send it to arithmetic combinator to change signal type.
Like this ("->" is green/red wire connection):
Chest with iron A -> decider combinator's input.
Chest with iron B -> arithmetic combinator's input.
Arithmetic combinator's output -> decider combinator's input.
Arithmetic combinator settings: left = "Iron", operation = "+", right = "0", output: any other signal, for example, "Copper". So you don't change value of signal (value + 0 = same value), but change its type.
Decider combinator settings: left = "Iron", operation = ">", right = "Copper", output: whaterver you need (describe what you want from this comparision if you need help).

Re: Compare two values of the same item

Posted: Sat Apr 29, 2017 12:54 pm
by Lav
If you only need to compare the amounts, a single arithmetic combinator is enough. Connect first chest to it's input, and multiply value by -1 (negative one). Connect combinator's output to the second chest.

You essentially get a difference between two chests, and can use that value in any triggers as necessary.

Note that this trick allows you to compare the amounts of any number of items in two networks - just set your combinator to All/All (i.e. process all signals and output them in a batch). I'm currently using this setup in my "make on demand" factory, except I compare the number of items in storage to values defined by constant combinators (i.e. requested amounts). Essentially, the entire factory setup is governed by a single arithmetic combinator. :-)

Re: Compare two values of the same item

Posted: Sat Apr 29, 2017 4:00 pm
by Kelderek
Specifically here's how you set that up:

Chest A connects to arithmetic input
arithmetic combinator set to Each * -1 output as signal Each to the decider's input
Chest B connects to decider input also
decider combinator set to compare iron plates > 0 output 1 for true as any other virtual signal (red, green, X, Y, A, B, etc.)

The comparison in the decider may be different depending on what you are trying to achieve, but if iron plates > 0 then you know chest B > chest A. If iron plates < 0 then you know chest A > chest B.

You may not even need the decider, you could just directly use an inserter or some other circuit controllable item if that condition is all you care about.

Re: Compare two values of the same item

Posted: Mon May 08, 2017 9:35 pm
by PitaPit
Thank you all for the very useful responses. I got a bit confused about the awesome fact, that the mods actually check my post first & thats why it took me so long to receive your solutions.
Keep on expanding your Factories.