Compare two values of the same item

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
PitaPit
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Apr 29, 2017 11:21 am
Contact:

Compare two values of the same item

Post 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.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2631
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Compare two values of the same item

Post 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.
Image

Transport Belt Repair Man

View unread Posts

PSS
Burner Inserter
Burner Inserter
Posts: 9
Joined: Tue Feb 12, 2013 8:01 pm
Contact:

Re: Compare two values of the same item

Post 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).

User avatar
Lav
Filter Inserter
Filter Inserter
Posts: 384
Joined: Mon Mar 27, 2017 10:12 am
Contact:

Re: Compare two values of the same item

Post 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. :-)

Kelderek
Filter Inserter
Filter Inserter
Posts: 250
Joined: Tue Nov 11, 2014 6:04 pm
Contact:

Re: Compare two values of the same item

Post 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.

PitaPit
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Apr 29, 2017 11:21 am
Contact:

Re: Compare two values of the same item

Post 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.

Post Reply

Return to “Gameplay Help”