Circuts: Add two item counts from different sources then enable/disable

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
ambbma
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Apr 13, 2023 8:07 am
Contact:

Circuts: Add two item counts from different sources then enable/disable

Post by ambbma »

I love factorio, and I think I've mastered all the gameplay concepts except circuits. I'm 500+ hours in and currently doing a SE run. I've spent a few /hours/ today trying to do this semi-basic task using circuits and I can't figure it out. I really really struggle with circuit logic and I think there are some game improvements that could be made to make this much easier. I'm a programmer by trade so - maybe I'm over complicating things or... I've read faqs and posts and I just keep getting more confused. I still don't understand how to use combinators or even really how they are *supposed* to work, other than some bizarre manifestation of basic boolean logic. Factorio seems to be missing some troubleshooting tools for circuits. Anyway, rant over. Here's my stumper:

I have 2 liquid containers - I'll call them A & B, and I have 2 pumps, I'll call them X & y. I want to enable both pumps if the contents of either containers are less than a certain level. In pseudo code I would do:

if ( a < 100 || b < 100 ) then enable X and enable Y.

Suggestions apprecited!

Loewchen
Global Moderator
Global Moderator
Posts: 8321
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

Re: Circuts: Add two item counts from different sources then enable/disable

Post by Loewchen »

Two deciders combinators, one with A as input one with B, each gets its relevant condition, both output S=1, both output wires combined and connected to both pumps. Pump condition is S>0.

User avatar
Nosferatu
Fast Inserter
Fast Inserter
Posts: 228
Joined: Fri Jan 20, 2017 4:48 pm
Contact:

Re: Circuts: Add two item counts from different sources then enable/disable

Post by Nosferatu »

If a and b are different liquids then it's very easy:
Connect all of them with red wire and set the pumps to start if "anything<100" no combinators needed.

Debugging: connect your output to a power pole then you can see the signal

Nidan
Fast Inserter
Fast Inserter
Posts: 227
Joined: Sat Nov 21, 2015 1:40 am
Contact:

Re: Circuts: Add two item counts from different sources then enable/disable

Post by Nidan »

ambbma wrote:
Mon Aug 28, 2023 3:11 pm
I'm a programmer by trade
factorio circuits are closer to... well... circuits than programming, even though they operate on 32 bit ints.
if ( a < 100 || b < 100 ) then enable X and enable Y.
you need to rewrite that in a way combinations can handle; each decider and device can only test one condition/comparison.
A hint, but the solution was posted in the meantime

Tertius
Filter Inserter
Filter Inserter
Posts: 673
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Circuts: Add two item counts from different sources then enable/disable

Post by Tertius »

ambbma wrote:
Mon Aug 28, 2023 3:11 pm
Factorio seems to be missing some troubleshooting tools for circuits.
Since the most simple solution has already been proposed by Nosferatu, I will only answer to this. There are multiple debugging helpers for circuits.
  • You can connect any circuit to a power pole. Move the mouse over that pole and you see the signals.
  • In the details of an entity connected to a circuit network, you see to what networks this entity is connected to. Move the mouse over the red or green network number: you see the signals on that network.
  • To see the signals going in and out of a combinator, hold the mouse over the combinator; you see it in the info tab on the right of the screen.
  • to single step each tick, switch the map to editor mode by using /editor in the console. In the map editor menu that appears, switch to the time tab where you find start/stop/single step/accelerate/decelerate functions; there are also hotkeys for this.

mmmPI
Smart Inserter
Smart Inserter
Posts: 2752
Joined: Mon Jun 20, 2016 6:10 pm
Contact:

Re: Circuts: Add two item counts from different sources then enable/disable

Post by mmmPI »

Nosferatu wrote:
Mon Aug 28, 2023 3:51 pm
If a and b are different liquids then it's very easy:
Connect all of them with red wire and set the pumps to start if "anything<100" no combinators needed.

Debugging: connect your output to a power pole then you can see the signal
i think it's cool but if one of the liquid run dry, it may happens that it get stuck because one is 0 and one is full the "anything <100" would not trigger, so i would add 1 constant combinator with signal of both liquid and value 1 to that red wire, to make sure the signals are always present to be under 100 and not 0.
ambbma wrote:
Mon Aug 28, 2023 3:11 pm
Suggestions apprecited!
the power pole to read value + /editor, to enter the editor mode and slow time to tick by tick are good tools. using lamps too, to control simple things, having a lamp flash, potentially with a color to avoid looking at dozens of power poles to find the values.

also sometimes the "simpler" things you can think of are complex using the circuits , while when experimenting with the combinators without real purpose, you only have to find game situation to utilize the behavior you discovered, which is easier :) such as the fact that things connected with the same color of wires shares the same values, which are summed up. ( this is why the liquid needs to be different ).

Post Reply

Return to “Gameplay Help”