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
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.
Inserter Item Pickup Logic
Re: Inserter Item Pickup Logic
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.
Re: Inserter Item Pickup Logic
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.
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.
Re: Inserter Item Pickup Logic
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.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.