Lazy mode for inserters (to prevent jams)

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

Post Reply
AntiBlueQuirk
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Wed May 03, 2017 2:57 pm
Contact:

Lazy mode for inserters (to prevent jams)

Post by AntiBlueQuirk »

TL;DR
Inserters should have a "lazy mode" that makes them not pick up things they don't have room for, and not drop things on the ground, to prevent "inserter jam"

What ?
Inserters are very powerful, with many behaviors and uses. They can pick things up off the ground and out of inventories, as well as put things on the ground and in inventories. Depending on what they're facing towards, inserters' behavior changes a lot. If they're facing the ground or a belt, they'll pick up basically anything that's behind them, and try to place it in front of them. If they're facing an "untyped" inventory with empty slots, they'll do the same thing. However, if the inventory they're facing is "typed" (like an assembler) or is already full of items, they'll refuse to pick up a new item until they know what they need, and that they have room for it. This works totally fine as long as their target doesn't move, and is why inserters facing assemblers never jam.

Basically, as long as the inserter has a target that can only fit some items, it will only pick up items that fit. If they have a target that can take anything (belt or ground), then they'll pick up anything. As an example consider when you are loading items into a vehicle. As long as the vehicle is parked, the inserter will only pick up what will fit. However, as soon as the vehicle moves, the inserter's target is suddenly the ground, so it will pick up anything again. Some of your items will end up on the ground, and worse, the stack in the inserter's hand may not actually fit when the vehicle parks again, causing it to jam. This is why trying to load multiple types of items into a train or car with a single inserter is so hard.

So what I propose is that inserters have a checkbox in their UI that switches them into "lazy mode" (or "conservative mode" or "non-greedy mode"). An inserter with this enabled will function normally when facing an inventory, but when facing the ground, will refuse to function. Basically, an inserter in this mode will only pick up what it has room for (like normal), AND checks that it has a non-ground target. If the target is a belt, then the inserter will grab any item behind it, but only if the belt isn't full. (More on belts below.) I think in this mode, the inserter should also limit it's stack size to what will fit. (So even if the inserter could normally pick up 3, it will only pick up 2 if that's all the room there is. I'm not actually sure if this happens in all cases right now.)
Why ?
This would greatly decrease the number of inserter jams when trying to load things into vehicles. It wouldn't eliminate all jams, I'm sure, but it would help a lot. (Even assembler inserters can jam if you manually insert things.) In a sense, it's just a checkbox that tells the inserter to be more careful about picking things up. I haven't read the code (obviously), but I don't think it would be hard to implement either. Inserters already change their behavior based on their target, and already know how to "pick up what fits". The only cases where they don't check to see if things fit is with the ground and belts. So, if a lazy inserter is facing the ground, just don't pick anything up. They even already "sort of" do this if train tracks are in front of them, but can still pick up too much of an item type. Checking "will it fit" with belts might be expensive or error-prone, so I'd be okay with lazy inserters ignoring belts too.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: Lazy mode for inserters (to prevent jams)

Post by ssilk »

How do you handle this case:
- The inserter picks up an item to deliver into the car/whatever vehicle
- while he turns around the car drives away
- Inserter is stuck left with items in his hand, that cannot be inserted anywhere.

Or the similar case: How do you handle the case, that the player inserts so much items, that an inserter cannot insert anymore.
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

AntiBlueQuirk
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Wed May 03, 2017 2:57 pm
Contact:

Re: Lazy mode for inserters (to prevent jams)

Post by AntiBlueQuirk »

There would be no solution to the first case. Some people propose allowing the inserter to "turn around" to fix it, but this is a much more complicated change, and could cause even more problems. (What should a chain of inserters do when it backs up?) All I'm proposing is to have the inserter be more careful when it picks stuff up, to avoid this situation in the first place. Any inserter holding more than one item will jam if you pull the inventory out from under it.

To address the second case, this switch would also have them prefer smaller stack sizes, (i.e. only what they think will fit), so that they don't end up with a partial stack in their hand. Let's say you have a inserter moving coal and wood from one chest to another. As long as there's plenty of room (more than the stack size) it works normally. If there's only room for 3 coal, it'll only pick up 3, even if it's stack size is 10. If there's room for 3 coal and 3 wood, it'll pick up 3 coal, move it, then pick up 3 wood and move it. After that point, the chest is totally full, so it won't pick up anything until there's more room.

The lazy mode switch would not fix every situation. There would still be cases where jams could occur. (You can even jam an inserter-to-assembler in some cases.) But it would greatly reduce the cases where a jam could occur, and would be useful for many things.

Post Reply

Return to “Ideas and Suggestions”