Factorio

Factorio

View Stats:
chest filtering, is it possible?
i have 2 different items going into a single chest but want to limit how many stacks of each can appear in that chest to prevent 1 item from overtaking the chest
< >
Showing 1-11 of 11 comments
PunCrathod Jun 7, 2021 @ 12:34pm 
Easiest solution is to use two chests. But if you really want to use a single chest then you need to use circuits to turn off the inserters when there is enough items in the chest.
Fel Jun 7, 2021 @ 12:37pm 
It isn't possible with chests but it is possible with other things like a cargo wagon so you could get clever and build just enough rails to put down the wagon to act as a chest (that takes a whole lot of space but can be filtered).
THE kilroy Jun 7, 2021 @ 12:54pm 
A solution could be a filter inserter(or 2 separate inserters) enable and disable based on chest contents

You CAN use a car and filter its inventory
Last edited by THE kilroy; Jun 7, 2021 @ 12:55pm
Rezznor7 Jun 8, 2021 @ 1:58am 
Sort of. While putting a filter on a chest itself is not possible, if the 2 different items are being fed with 2 different inserters, then you can connect a red or green wire from the chest to each inserter, and have the inserters only activate when <item> < #.
RiO Jun 8, 2021 @ 12:51pm 
Just enabling/disabling inserters with circuit control won't cut the mustard, as inserters carry stacks. You also need to limit stack size on the last grab.

What I usually do is compute the difference between desired and actual of item in an arithmetic combinator, then output that to an inserter set up to enable based on the condition {diff} > 0 and then also assign {diff} as the stack size.

If you assign a value greater than the max allowed stack size, the inserter will auto-cap at the max allowed. If you assign a value less than 1, it will auto-cap at 1. (And at 0 the enable condition trips and the inserter disables.)

This way you always get count-perfect fills on your chests; assemblers ( ::cough:: Kovarex process ::cough:: ) or wherever else you need. And it will have maximum stack size - i.e. maximum throughput - for as long as it can.
Or, just use a train wagon and use middle mouse button to set a filter.
Gregor Samsanite Oct 17, 2023 @ 5:36pm 
Filter Chests mod. Lets you filter any chest like a train wagon.
Last edited by Gregor Samsanite; Oct 17, 2023 @ 5:37pm
Chindraba Oct 17, 2023 @ 6:35pm 
The use of a circuit will be required to limit the count of items in a chest. The hand size can be a problem in some cases, and has various work around options. Limiting hand size to 1 is the most obvious, but then you're loosing out on the benefits of hand size research and really missing out on the stack inserter's capacity. I have two variations I use depending on how important the actual count is and if I am using one inserter for each item or a single inserter for all of them.

The vast majority of the time I'm using the chest where I want to have some of each item but don't care that the balance be exactly correct. In the mall I like to have a few stacks of level 1 and level 2 modules available for when I do exact ratios on a build, while most of the time I use level 3 modules. So I need to have 6 different items in one chest with 200 of each level 1 and 400 of each level 2.

The easy imprecise method is to plan the counts for each item so that in the numbers are exact you will have at least 1 empty slot for each item in the chest. For my modules example that would be 6 empty slots, or 42 available. For only two items that would be 2 empty slots and 46 available.

I'll use train stops, rail chain signals and rail signals as the example since they have different stack sizes and that will help show how the parts work. Let's say that I don't need very many train stops available. 100 ought to be plenty for building purposes. I need a lot more rail signals, yet I probably don't need a massive amount. So, let's work with 850, I'll guess that I need 2/3 as many chain signals as rail signals, or about 550

100 train stops, with a stack size of 10, is 10 slots in the chest. The 850 rail signals, with a stack size of 50, is another 17 slots. Lastly, the 550 chain signals, also with a stack size of 50, is 11 slots. I need 10 slots for train stops, 17 slots for rail signals, 11 slots for chain signals and 3 empty slots for the "system", so the total is 10 +17 +11 + 3 = 41, which is safe as it leaves 7 extra slots, just in case I decide to put something there manually. (Of course, as usual, once I do that I will completely forget where I stashed the extra inserters when I needed a few empty slots in my personal inventory and have to go get more from the mall.)

If it's one inserter for each item, then no combinators are needed, just some wire - either color. I can also use either filter inserters (purple) or stack filter inserters (white). The train stop inserter has the filter set to "train stop". Connect a wire from the chest to the inserter. Set the inserter's enable condition to "train stop < 100". The next inserter is filtered to "rail signal", connected by a wire to the chest, and enabled for "rail signal < 850". The last inserter is filtered to "rail chain signal", connected to the chest by a wire and enabled when "rail chain signal < 550". It is possible to connect each inserter to the chest and which color is used doesn't matter even if two are green and the other is red. Or connect one inserter to the chest, the next to the first, and the last to the second in a daisy-chain connection, as long as the same color is used the whole way.

What happens. Let's say that inserter hand size has been researched all the way up and stack filter inserters are used, so the hand size is 13 items per swing. Looking at the rail signals, if the chest has 850, or more, the inserter is disabled. If there are less than 850, the inserter is enabled. It will pickup as many as 13, if the belt has that many available and place all of them in the chest. If the chest already has 840 then the 13 the inserter adds will make 853, 3 more than the limit. Since there's the planned 1 empty slot per item, the extra 3 will use that slot. It's a bit of a waste of space, 3 in a slot that could hold 50, but it's easy to make work. If luck is good, there will be 837 in the chest and the 13 will make exactly 850 and the inserter will be disabled. The chain signals will work exactly the same, with a limit of 550 rather than 850. The train stop will be a little different, in the numbers, but not the effects. A stack inserter, or stack filter inserter which can grab 13 will only grab a max of the item stack size. So picking up train stops it will never grab more than 10, and grabbing nuclear fuel or artillery shells it will only grab 1, even though the research says it can handle 13.

There's another possibility here. The rail signals and chain signals are same recipe, and could be made in the same place with each getting a half-belt of output. If we add a couple combinators we can use one inserter for both items. The effects are different between the filter inserter and the stack filter inserter but the circuit is the same. The setup is to use an arithmetic combinator with the input connected to the chest and the output connected to the inserter. Add a constant combinator connected to the output of the arithmetic combinator. The color of wire on the chest doesn't matter, but the two wires on the output of the arithmetic combinator have to match, either color is fine, as long as both are the same color. The settings on the inserter are only "Set filters". The arithmetic combinator is set to do zero minus each, output each (Each is the yellow star symbol.) The constant combinator is set to what the limits are, so for this it would be rail signals = 850 and rail chain signals = 550. There isn't really a limit, in theory, of how many things you can filter for though in practice you cannot do to many or the belts start to get clogged.

How this works. The constant combinator outputs how many we want. The contents of the chest get turned into a negative number by the arithmetic combinator. The system always adds the signals together when two, or more, wires of the same color connect, so the negative number from the arithmetic combinator is added to the positive number from the constant combinator with the result going to the inserter. The inserter, when the operation is "Set filter" doesn't care what the number is, only that it is greater than zero. So any positive number signal will "turn on" that filter. 700 rail signals in the chest becomes -700 rail signals on the output, and the 850 from the constant combinator is added to that and the inserter sees 150 rail signals, and turns on the rail signal filter.850 rail signals in the chest becomes -850 on the output, added to the 850 we requested is 0, so there won't even be a rail signal on the wire that the inserter sees, and the rail signal filter will be off.

The difference in behavior of the filter inserter and stack filter inserter could be a problem here, and needs explaining. The filter inserter can have up to 5 filters set while the stack filter inserter can only have 1 filter set. What happens is that the stack filter inserter will pick the item with the lowest internal ID as the one to use. I've never looked to see what the ID values are, but I do know the order they are in. The order of the ID's matches the order of items in the GUI when selecting a filter. It's the same order as what is in the crafting menu except there are things in the crafting menu which are not in the filter menu, for example Uranium processing. It's a recipe you can set on a machine, but not an 'item" you can filter. In this case, the rail signals will be filtered by the stack filter inserter first. And, that's where a problem can happen. With a half-belt each of the two signals, the filter inserter will pickup any rail signals it can find. If it don't find any it will pickup chain signals instead, switching back to rail signals if one becomes available. The stack filter inserter, however, will get stuck waiting for rail signals until the chest has what is requested - then it will start loading chain signals. If something happens in the factory and the rail signals stop getting onto the belt, the stack filter inserter will keep waiting for rail signals, and never load any of the chain signals. The filter inserter will use the same process to pick the 5 filters to use if the list is bigger than 5 as well, it's just less often a problem - like here where there's only the two signals to begin with.

I'm sure I've missed something, but can't bring it to mind. It's well past time for me to be sleeping instead of answering posts on Steam. If this is helpful, great. If something's missing maybe I'll see the question and be able to answer it better once I wake up.
PunCrathod Oct 17, 2023 @ 11:09pm 
Nice necro.
Chindraba Oct 18, 2023 @ 1:53am 
Originally posted by PunCrathod:
Nice necro.
Dang it. I didn't even look at the OP date, just opened what showed up in the list as recent, looked at the current answer, reviewed to question, and started my answer.
good4usoul Dec 6, 2023 @ 8:34am 
I'm glad you responded. You answered the question I was looking for: Does the "set filters" circuit connection override the limit of items filtered of a filter inserter. Your answer was no, and only items with lower internal ID are passed to the filter inserter when the limit is exceeded.
< >
Showing 1-11 of 11 comments
Per page: 1530 50

Date Posted: Jun 7, 2021 @ 12:30pm
Posts: 11