Red/Green circuit network comparisons

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
pofigismo
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 7:16 am
Contact:

Red/Green circuit network comparisons

Post by pofigismo »

So i've gotten into circuits just now and within 15minutes of playing around I ran into a problem - there doesn't seem to be a good way of comparing values from red and green circuits. So lets imagine this situation:

Red circuit content:
10 gears
10 iron plates
10 copper plates

Green circuit content:
5 gears

Now I want to create a statement along the lines of:

For <item> in <red circuit>
if <item> is less than <same item in green circuit>
send out signal A with the value of (<item in red circuit> - <item in green circuit>)

so that in the case of gears I get an output in the green circuit of Ax5, since the difference between gears in two circuits is 5.

This is possible to do if the items are pre-determined and there's a low amount of different items, since we can output a specific item's count as some other item, BUT - that requires dealing with a huge set of temporary replacement values for each item and in the end it's pretty much impossible to do if I want the logic to apply to a big set of different items.

As such my question is - is there any way to compare values of the same item from different circuits without converting the item's count to a different signal with the same count (as this would be the absolute opposite of automation - requiring to manually configure hundreds of different items and their replacement values)


Edit:

It is also good if I could at least do this:

For <item> in <red circuit>
if <item> is less than <same item in green circuit>
send out signal A to red circuit
else
send out signal A to green circuit
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

Re: Red/Green circuit network comparisons

Post by Choumiko »

You can multiply each signal of one color by -1 before connecting them, then you can decide what to output depending on whether the result is negative, 0 or positive.
pofigismo
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Mar 21, 2016 7:16 am
Contact:

Re: Red/Green circuit network comparisons

Post by pofigismo »

Choumiko wrote:You can multiply each signal of one color by -1 before connecting them, then you can decide what to output depending on whether the result is negative, 0 or positive.
Genius. How did I not think of this - thanks a lot! :)
Post Reply

Return to “Gameplay Help”