Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
ribsngibs
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Mon Mar 28, 2016 5:42 am
Contact:

Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by ribsngibs »

When you use a circuit signal to set the filters on a filter inserter, the filter inserter only chooses the "first" 5 items in the signal (and a stack filter inserter chooses only the first item).

I'm trying to design a single centralized rail station which demands certain numbers of items with a circuit network signal. For the simple case this is a super well known problem - anybody designing a remote outpost with item limits set by circuit network has already solved this - send a signal for desired items: perhaps 50 walls, 10 turrets, 50 repair packs, subtract the signal for how many of all these items you already have at the outpost (perhaps 30 walls, 10 turrets, 47 repair packs), send the result (20 walls, 3 repair packs) to filter inserters and also set the train limit to the outpost resupply rail station to 1 if necessary, and now you have outpost supply trains that only deploy if there is a shortage, and it is easy to upgrade every already-placed outpost, by changing the 'desired items' signal.

The problem I'm running across is that I want to design a very large version of this kind of automated rail station, with many items that can't possibly fit on a single train car (I want to use one to supply an 'everything' mall, and another one to supply cargo rockets in space exploration). If all desired types of items can fit onto a single train there is no issue with the fact that only 5 or 1 items is used by the filter inserter because the inserter will eventually deliver enough items that those signals will drop to zero, exposing the other item signals, and eventually all requests will be fulfilled.

With multiple trains that can arrive with different items, now there is a problem. If, for example, I am requesting every kind of belt and underneathy and splitter and chest and pipe and assembler and miner and so on, and the first 5 items that the filter inserter happens to select are the yellow belt/underneathy/splitter and the red belt/underneathy, but the train that has just arrived is filled with only assemblers and chemplants, then the filter inserter will not do anything.

I was wondering if anybody had any ideas of how I could get this "how to get specific numbers of items from a single rail station with many kinds of trains arriving" problem solved. I was thinking I could cycle through groups of 5 items at a time on my signal, so perhaps on tick 1, signals for yellow + red belts are sent to the inserter, on tick 2 signals for assemblers and miners etc. are sent, on tick 3 prod modules, on tick 4 speed modules, on tick 5 eff modules, tick 6 refineries, pumpjacks, and chemplants, and so on. But this seems like a nightmare to set up (and hard to extend - every time I add 5 more kinds of items to my requested item list, I have to adjust this looping cycle system), and I don't even know if I can design a reasonably sized system that can loop through the signals like that. Can't think of any other solutions.

I've found some other posts like viewtopic.php?t=50220 where people are asking about features to increase the number of filter slots but I want to see if I can work around the limitation as it exists now.

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

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by mmmPI »

ribsngibs wrote:
Mon Apr 01, 2024 3:28 am
but the train that has just arrived is filled with only assemblers and chemplants, then the filter inserter will not do anything.
To me that's where the problem is. Even if inserters could have 1202101 filters, if the train that has just arrived is filled, then the inserters can't do anything. This train needs to go, or better never come in there to begin with.

If it's partially filled with say item (F) but the inserters have as filter (A) (B) (C) (D) (E) because you requested item (A) (B) (C) (D) (E) (F) and you expect the inserters to fill in the available room of item (F), you can't solve that with just inserters filters apart from using combinator builds, we need to know more about how and why you would request more material than can fit in a single train and use filter for all items even though they can't fit in the train.

It's a situation where inserters without filter would work better, so why are they allowed to pick wrong material and be forced to filter ? Are they picking up from a requester chest that contain items not requested by the trains ? That's easier to solve, stop requesting items that you don't want on the trains on those chests, this way no need to filter inserters, sure they may pick a wrong item fom here to there when changing items, but you specifically encounter this problem because you made a large request you expect to be fulfilled by several trains, therefore it will be picked up by another train, it won't stop, just deliver little extra.

Imagine you requested 100K yellow belts, and 12 splitters, it's possible that a train arrives and pick up the last yellow belts , so that its cargo is almost filled with yellow belts, except the last slot which is 50% filled or maybe the last 2 slots that are 50%, or the last 3... to me that's the same situation, this can be dealt with inactivity conditions.

What do you expect to happen here ? the trains needs to go right (inactivity) ? And the few inserters that may have picked up belts that they couldn't fit in the train should either put them in the next train OR not have been allowed to pick them in the first place ( changing the supply/request) with some sort of decrementing stack size or a special inserter that deal with item whose quantity left to fulfill the request are smaller than say 50 so it's only 1 inserter that is left doing the precision counting to avoid picking up extra items.

Qon
Smart Inserter
Smart Inserter
Posts: 2119
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by Qon »

I have a blueprint for allowing any amount of filters in a stack filter inserter. It is guaranteed to not miss any items on a belt (with electricity), but the technique could easily be adapted for choosing the right filter to use for a train.

Attachments
Screenshot from 2024-04-01 12-43-05.png
Screenshot from 2024-04-01 12-43-05.png (153.83 KiB) Viewed 449 times

BaggyK
Inserter
Inserter
Posts: 35
Joined: Fri Mar 01, 2019 12:22 pm
Contact:

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by BaggyK »

ribsngibs wrote:
Mon Apr 01, 2024 3:28 am
The problem I'm running across is that I want to design a very large version of this kind of automated rail station, with many items that can't possibly fit on a single train car (I want to use one to supply an 'everything' mall, and another one to supply cargo rockets in space exploration). If all desired types of items can fit onto a single train there is no issue with the fact that only 5 or 1 items is used by the filter inserter because the inserter will eventually deliver enough items that those signals will drop to zero, exposing the other item signals, and eventually all requests will be fulfilled.
One possible solution is to read the train contents from the train stop, and use that to filter the filters.

So create the list of needed items, then filter out any items that are not in the current train, and then use that to set the filters on the inserters.

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

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by Tertius »

ribsngibs wrote:
Mon Apr 01, 2024 3:28 am
With multiple trains that can arrive with different items, now there is a problem. If, for example, I am requesting every kind of belt and underneathy and splitter and chest and pipe and assembler and miner and so on, and the first 5 items that the filter inserter happens to select are the yellow belt/underneathy/splitter and the red belt/underneathy, but the train that has just arrived is filled with only assemblers and chemplants, then the filter inserter will not do anything.
I guess my supply train solution is able to handle this setup. As long as you're not trying to make more than 1 wagon with the same item and not carry the same item in different wagons across different trains.
As far as I see, you accept different loading stations to load different trains, but want one universal unloading station that's able to unload different trains.

My approach works like this. It's just intelligent adding, subtracting and filtering the list of items to move.

The vital step and core principle is to exclude items not on the train from the list of items to unload. So they will never appear in a filter list in the first place.

We have:
- the train content. All items the incoming train currently carries.
- one constant combinator per wagon that defines the items to unload from that wagon.
- one storage. All items already present at the target. Can be either the reading of chest content or the reading of the logistics network. Reading the logistics network will work, but makes the unloading slightly inexact and destroys junk disposal. For the sake of this example, I assume I read the content of all chests the inserters will unload their items into.

1. with one wire color, we wire all the constant combinators for all wagons together, so we have a list of all items we want being unloaded. This is the global demand. Call it D. Let's call the train content T. The global storage content S.
2. Negate the demand (multiply by -1) and add the train content you read from the station. This is T-D.
3. Add the storage content. This is T+S-D. Both the train content and the storage content are the items we have, and the combinator content is the items we want.
4. In 3., all items not available, neither in the train nor already in our storage, have negative values.
5. filter EACH < 0, so we have a list of items not available only.
6. negate the storage content and add it to the list from 5. This gets T+S-D-S = T-D but the items not available filtered, so it's the negated value of items actually available from the train minus items already present locally. This is the crucial step. Call this -A.

This is per wagon:
7. per wagon, add its associated constant combinator with a different wire color to -A. Don't pollute -A with that value, but feed one color with one signal and a different color with -A to a decider combinator. Filter ANYTHING > 0. This gets one item from D-A, which is demand minus items already present or not on the train in the first place. This is what we will actually unload.
8. add one final combinator with EACH > 0 and S=input count, which gives us the stack size of that item into S.
9. feed the output from 7. and 8. to a stack filter inserter.

This setup will never stall the stack filter inserters.
If the list of items to unload from one wagon is too big for one constant combinator, chain multiple constant combinators. Wire them with both colors, because both colors are used - one color for getting the global demand, one for inserter operation per wagon.
Untitled.png
Untitled.png (736.58 KiB) Viewed 429 times

In theory, you need an additional combinator per wagon with a NOP to make up for the 1 tick latency with computing the stack size. It's missing, so the first item that is moved is moved with no stack size, which will be interpreted as 1 by Factorio. This is never wrong and a tiny performance impact that results in 1 additional inserter swing per train visit.


This is the actual station I'm using - it has added functionality. I created above to show the general approach. The actual station has only 3 wagons for items, and the 4th is for bringing junk back to the base. It also has a means to bootstrap robots into an empty logistics network and keep the number of robots constant - that special station is meant to support the perimeter defense which always have a constant small drain of everything.
Screenshot 2024-04-01 133922.png
Screenshot 2024-04-01 133922.png (5.02 MiB) Viewed 429 times


If this is kind of what you need, I can also show the corresponding loading station. In my base, I have 4 different supply trains with this generic setup. One for perimeter wall defense supply, one for mining outpost building supply, one for supplying the external research facility with nuclear fuel, and one for an artillery train + special artillery outpost I use to clear new terrain.

Illiander42
Filter Inserter
Filter Inserter
Posts: 409
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by Illiander42 »

This feels like you're after a stock LTN station?

How is what you're after different?

ribsngibs
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Mon Mar 28, 2016 5:42 am
Contact:

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by ribsngibs »

Ahh… so simple and I feel so dumb. Get train contents, do logical AND with signal of requested items, send to filter inserters. Thanks for the help everybody. I had kind of forgotten you could read train contents from the rail stations as this is “new” functionality since the last time I really played a long game.

To answer people’s questions, yes the idea is to have lots of different, separate loading stations, which makes sense for a modular base - you have a green/red/blue circuit block with a train that loads up from there, a block that makes all kinds of belts, a block that makes modules, etc.. and then I want to make a centralised dropoff with a single train unloader which can request anything at all. It won’t be the fastest, but not every use case needs to be the fastest!

And this may be a built in LTN rail station, I don’t know - I am not using it. I’m running with the space ex mod but playing more or less stock aside from that.

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

Re: Best way to get around the "filter inserters only have 5 filter slots and stack filters only 1" constraint?

Post by mmmPI »

I think you have your answer already, but thank you for adding the precisions and use-case nonetheless. Maybe it will help me orienting player better next time because clearly i misunderstood the problem this time :oops:

It is a difficult task you are planning for, LTN mod to me seem designed for the way you want to use trains, allowing to overwrite the regular train schedule logic and replacing it with a system of requester, provider and some depot stations for multipurpose trains. It is not "easy" to get into, but still probably "easier" than doing it without the mod. That may not be what you are after though :D

The "limit incoming train" feature may help you replicate some of the behavior but using more than 1 train to go faster seem difficult anyway, or a fun challenge !

Post Reply

Return to “Gameplay Help”