Inserter Item Pickup Logic

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Dire
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Mar 03, 2025 12:13 pm
Contact:

Inserter Item Pickup Logic

Post by Dire »

How exactly an inserter decides which item to pick up?

Context: I challenged myself to make a space platform that makes space science using only the 46 space foundation that comes with the starter pack, so I need to get the most out of every inserter. My setup is in the screenshot below (and blueprint here https://factoriobin.com/post/uy9d62, though the preview image is off) and the key inserter is the one at the bottom, which is filtered to metallic/carbonic/oxide asteroids, iron ore, and carbon (in that order), and set to activate when carbon in the hub is >20.
Screenshot 2025-05-03 at 10.00.11 AM.png
Screenshot 2025-05-03 at 10.00.11 AM.png (2.9 MiB) Viewed 452 times
Screenshot 2025-05-03 at 10.00.11 AM

The behavior I want from that inserter is: whenever carbon builds up too much, this inserter vents all asteroid chunks and iron ore (which are just trash), and only then throws out carbon. I was hoping filters would also set the priority for which items are moved, so the inserter would try to move an asteroid chunk, then iron ore, and only if it couldn't move either of those would it move carbon.

What actually happens is: the inserter seems to throw things at random, so over time iron ore builds up and clogs the system.

Is there any way to change this inserter behavior to make it deterministic? Or is it actually deterministic and I'm missing some deeper logic?

P.S. Obviously there are ways to handle this with more complicated circuit logic, or even just a second inserter that is always active and vents the iron and chunks. But those add an extra tile and I'm interested in making a perfectly-minimal design.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4011
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Inserter Item Pickup Logic

Post by boskid »

Inserter behavior is deterministic. It goes over output inventory of the pickup target and visits item stacks from last to first. First item stack that matches filters and can be inserted into a drop target is grabbed. There may be some problems with the hub itself because hub inventory often contains a lot of items so we do not want to sort hub inventory when not needed but it gets sorted when player has hub open.
Tertius
Smart Inserter
Smart Inserter
Posts: 1317
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: Inserter Item Pickup Logic

Post by Tertius »

The most space consuming way to reliably get rid of arbitrary unwanted items is probably to add a constant combinator with a list of every possible wanted item with wanted quantity as negative numbers.

Connect this to the inserter, as well as the platform inventory, and set the inserter to set its filter from circuit network. No activation condition. This way the actual filter is every item where the amount of existing items is higher than the wanted amount, so only the surplus has positive values. As soon as the amount gets lower, it will become negative and vanish from the filter. In case there is no unwanted item, the filter is empty, and the inserter will do nothing no matter if it is activated or not.
Use a a fast inserter in case unwanted items accumulate faster than they're being thrown away.
Dire
Burner Inserter
Burner Inserter
Posts: 5
Joined: Mon Mar 03, 2025 12:13 pm
Contact:

Re: Inserter Item Pickup Logic

Post by Dire »

boskid wrote: Sat May 03, 2025 2:29 pm Inserter behavior is deterministic. It goes over output inventory of the pickup target and visits item stacks from last to first. First item stack that matches filters and can be inserted into a drop target is grabbed. There may be some problems with the hub itself because hub inventory often contains a lot of items so we do not want to sort hub inventory when not needed but it gets sorted when player has hub open.
Thanks for the quick reply! Knowing this, I was able to fix the problem by changing the inserter to activate on iron ore>20. It's slightly annoying that you can't control the priority behavior like you can with turret filters, but I'm guessing that's there for performance reasons.
Post Reply

Return to “Gameplay Help”