Combinators: How to pick one item type from many?

Don't know how to use a machine? Looking for efficient setups? Stuck in a mission?
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Combinators: How to pick one item type from many?

Post by mrvn »

I have a chest (actually a hauler from the AAI mod, but chest is the simplest analog) with iron ore, copper ore, raw wood, coal, ... many different items in it.

Now I need some circuit logic that picks one item type present in the chest and outputs a number N for it. E.g. N=1 for raw wood, N=2 for coal, N=3 for iron ore and so on. I'm looking for a simple circuit with short and constant signal path that outputs either the number for the item type with the most items or the item type with lowest or highest number. In a pinch a random number would also do.

My current solution assigns a power of 2 to each item type, adds all the present item types up and then figures out the lowest set bit and converts that into the item type number. Has a path length of 4 combinators and a constant combinator and 2 decider combinators per item type. Problem is that only works for 30 items and with Bob's mod I have more items. So I would have to cascade that. I'm looking at around 150 combinators just to pick one item type out of a chest.

So any better ideas?


mrvn
Smart Inserter
Smart Inserter
Posts: 5682
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Combinators: How to pick one item type from many?

Post by mrvn »

thanks

Post Reply

Return to “Gameplay Help”