Identify and set stack size based on input signal.

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
DEFENESTRATOR-666
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Apr 29, 2021 9:14 am
Contact:

Identify and set stack size based on input signal.

Post by DEFENESTRATOR-666 »

I have a basic setup for train stations that lets me set what resource goes in and out manually. The deciders at each station keep track of how many trains worth of resources are available and how many are being requested, I then use this information to decide what resource is the bottleneck and expand accordingly.
The problem is that setting up these deciders has gotten quite tedious after the 100th time, so I was looking to automatize the process.

I have set up a few constant combinators outputting virtual resources at their max stack size. Image
I want to use this basic info to, based on the contents of the chest, output only the corresponding signal.
For example, if I have only iron ore loaded into the chests, the deciders output only the 50 iron ore signal from the constant combinator.

The way I went about to solving this was to first identify the chest contents and set that value to 1. This value and the ones from the constant combinators is added to an arithmetic combinator that has the setting "EACH - 1, output EACH" (to account for the +1 you get from the chests). This yields a bunch of values that end in 9 and the value that I want to isolate being unchanged. So the way I isolate this is (this is the part I don't like most) pass these values through a series of decider combinators that have the setting "EACH = STACK_SIZE, output EACH", where the stack sizes are 10, 20, 50, 100 and 200 respectively - so I have 5 combinators to find out one value. (I decided to test for liquids differently since they all have the same "stack" size)
This works, but I really don't like the solution as it's very space inefficient and I feel like there's a more elegant way it can be done.
Here is the BP:

This uses some K2 and SE signals so they might not appear in your save if you don't have those installed.
Any suggestions or improvements would be greatly appreciated.
DEFENESTRATOR-666
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Apr 29, 2021 9:14 am
Contact:

Re: Identify and set stack size based on input signal.

Post by DEFENESTRATOR-666 »

I ended up just going with that design in the end. Now the only thing I do to set up a new requester or provider station is to change the name of the station itself, the rest gets sorted out as soon as the chests have items in them.

There's still some noise in the circuits (I have to get rid of something that goes ^2 somewhere along the way). That can probably be fixed eventually but I don't want to spend time on this problem anymore.
Here's a rough overview of what the requester station does:
Image
The provider station works similarly.
Any suggestions welcome!
Post Reply

Return to “Gameplay Help”