[1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Bugs that are actually features.
Post Reply
Suslik
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Jun 23, 2023 5:18 am
Contact:

[1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Post by Suslik »

This is an old issue and not specific to any of the newer versions as far as I know.

Imagine you have two cargo wagons. Each wagon has filters set up, where one slot is reserved for copper plates and one slot is reserved for iron plates, all other slots are disabled. The first wagon is full (with one full stack of copper plates, one full stack of iron plates), the second wagon is half-full (~half stack of iron plates, ~half stack of copper plates).

Now imagine you put an inserter (long-handed, obviously) to move stuff from the first wagon to the second one. Most of the time it will top up both the iron and copper plate stack of the second wagon using resources from the first one, but occasionally it will top up say the iron plates stack and then instead of picking up a copper plate it will pick up another iron plate and get stuck, since there's no place for it in the destination.

This problem is much more pronounced if you put a filter to a different kind of item into every wagon slot (say, one slot for iron ore, one slot for iron plates, one slot for iron gears, etc etc) and start moving resources between wagons using long-handed inserters. It's also made worse by high-capacity inserters and if you move stuff in and out of these wagons at the same time either manually or to supply assemblers for examples. However, it does indeed sometimes reproduce with just 2 wagons, 2 resources and 1 inserter.

This setup is useful for creating train/vehicle-based malls for example and all sorts of other things such as mixed train stations.

Expected behaviour:
I expect inserters to never pick up an item if the destination has no room for it. There can be further complications if the destination gets full due to something else topping it up while inserter is "in flight", then the only solution would be to "reserve" space in the destination container as soon as inserter picks up an item, but I'm not sure if that's feasible.

If this issue is hard to reproduce, I can provide an exact screenshot and/or save file.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Post by Rseding91 »

Thanks for the report however this is not a bug. The inserter will never grab an item if at least some part of it will not fit into the destination. However It will grab as much as it can up to the stack size limit of the inserter each swing. If not all of those items will fit then it will sit and wait at the destination until it can place them into it.

If you don’t want it to grab that many items each swing you can set it to grab less per swing in the inserter GUI.
If you want to get ahold of me I'm almost always on Discord.

Suslik
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Jun 23, 2023 5:18 am
Contact:

Re: [1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Post by Suslik »

It's quite unfortunate that it's not supposed to work with stack inserters, because it could allow very cool and efficient wagon-based factories and unloading stations.

However, I definitely did test it with non-stack inserters (limited stack size to 1 on long-handed inserters), and they still did get stuck. I placed 4 long handed inserters between every 2 wagons and they consistently ended up jammed after a while. Is it supposed to work in this case?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13242
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Post by Rseding91 »

More than one inserter is effectively one inserter with a variable stack size of 4. So up to 3 of them could get stuck at once if the first of the three takes the final slot.

They do not cooperate between each other about what other inserters are doing.
If you want to get ahold of me I'm almost always on Discord.

Suslik
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Jun 23, 2023 5:18 am
Contact:

Re: [1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Post by Suslik »

I understand that it's likely done this way to enable more efficient implementation, but still sad that it's never been a goal to make such setup work.

I guess the reason why it works for assemblers and does not work for containers is because assemblers request less items than the stack limit, so inserters never try to go over the limit. So technically the problem could have been solved if it was possible to "request" up to a certain number of items into a container, say half a stack instead of full stack, but then if some stack inserter goes overboard it still won't overfill. However, I understand that it's additional UI work and not an easy thing to implement.

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

Re: [1.1.85] Inserters get stuck when transferring stuff between containers with mixed filters

Post by Tertius »

See it this way: it's not a bug, it's just the way the inserter logic was built. It's extremely simple. Assume you're an inserter. You don't have eyes. You put one hand into a hole and feel what item you could grab from the top of the stack in that hole. Then you look up for space in the destination. Is there space for the item you just felt? If yes, you grab the item and put it into the destination. If not, you don't do anything but wait until there is space for that item in the destination.
You're not able to feel for other items in that hole. You just feel the one item you reach first. How that item is chosen if there are multiple items in the source container, you don't know. It's random. You know the top of it changes if things are inserted or extracted in general, but essentially, it's random, and as long as nothing is inserted or extracted, the item stays the same.

You have to understand this behavior and build a inserter setup that takes it into account. Often, things you want are not possible.

For example, to fill exactly some amount of an item into a container, you need to know how many items are already in it and how many items you want to have. Then you subtract the existing amount from the amount you want to have, then use this as stack size. This way you never grab too many items. In addition, to control which item exactly you grab, you need to use a filtering inserter. This filtering inserter needs to be given the item to grab as filter and as stack size the amount that's still missing from the container.

Unfortunately, you cannot read filters/reserved slots from a container, so you cannot iterate over the list of items, so you cannot do the above. But what you can do is using a constant combinator delivering signals and amounts for the items you want to have in the container. That's feasible. But using reserved slots in a wagon cannot be used to control an inserter.

In my opinion, this is a flaw in train and wagon handling and missing functionality, but in general there is no bug. You need to work against an inserter grabbing too much (by setting a stack size) but are unable to do this, because you cannot get the numbers from the container to compute the stack size. Actually, you are, if you are handling a train stopped at a station, but unfortunately you can only get the content of the whole train, not the content of each wagon separately. Reserved wagon slots play no part in that - they cannot be processed with inserter logic. To be honest, I don't see any use for them in the first place. Only if you want to insert only up to 6 different items into a wagon and reserve one inserter for each item, but that's really very limited.

Post Reply

Return to “Not a bug”