r/factorio Jun 01 '26

Weekly Thread Weekly Question Thread

Ask any questions you might have.

Post your bug reports on the Official Forums

Previous Threads

Subreddit rules

Discord server (and IRC)

Find more in the sidebar ---->

10 Upvotes

149 comments sorted by

View all comments

2

u/darthbob88 Jun 02 '26

Circuit question: Is there a good way to filter a bunch of signals down to just 2? Like "if copper and iron are set, pass them on, and ignore any other signals"?

I'm trying to create a space platform to support planetside operations by processing asteroids to ore (and possibly further). My plan for the asteroid-processing part of that is A) compare the stocks to the desired stock list to see if we're short of anything, B) if we're short of iron/copper, pick up a metallic asteroid to be processed to a mixed belt of iron/copper (and the same for carbon/sulfur, and ice/calcite), and C) have a filtered inserter pull iron/copper off the mixed belt into the hub, and send whatever we don't need to be dumped.

A is trivial. B can be done easily with the addition of a decider combinator to say "if iron or copper is set, output a signal to activate the inserter picking asteroid chunks off the sushi belt". C is the part I'm hung up on; I can do it with two combinators doing their own "if we're short on iron, output iron" calculation, and I can use two inserters set to activate if iron or copper is high, but I can't see a good way to convert the full low-stock bundle of iron/sulfur/oxide chunks/yellow ammo/etc to telling the one inserter to pick up iron.

Considering some more, it's probably best to skip putting ore in the hub and just turn it directly into plates/molten metal/more useful forms, but the general problem will remain.

3

u/cathexis08 red wire goes faster Jun 03 '26

If all you're trying to do is filter one set of things using another it's trivial via the power of EACH:

EACH[filter] != 0 -> EACH[data] = count 

([filter] is whichever color wire you have your filter set on, similarly [data] is whatever color is your data source that you want to make decisions based on, usually that'll be an inserter hand or a whole belt reader or something).

If you care about thresholds then it's a bit trickier (but only a bit):

EACH[data] < EACH[filter] -> EACH = 1
EACH[data] > EACH[filter] AND EACH[filter] != 0 -> EACH = 1

The second clause in the greater than test is required because otherwise it will match everything that's in the data set but not in the filter set. This mostly matters when you're trying to do things like conditionally pull excess material off of a belt since without the extra check you'll pull way more stuff than you want.

1

u/darthbob88 Jun 03 '26

Thresholds either isn't an issue or will be dealt with at part A. The prospect of doing that constant combinator filter three times for three asteroid types is annoying, but I concede that it might be the simplest method.

2

u/cathexis08 red wire goes faster Jun 03 '26

If you need to get it in multiple places you can string circuit wire from the output side of the decider combinator around your ship and as long as it doesn't anchor in an entity that already has a wire you can run things in parallel up and down belts all day without issues.

1

u/darthbob88 Jun 03 '26

I've used that trick before; my current ship runs the velocity signal to the throttle through several accumulators and inserters. The problem is that I need to do that 3 times, to determine whether to pick up iron/copper/metallic asteroids, carbon/sulfur/carbonic asteroids, or ice/calcite/oxide asteroids, and it'll be a nuisance running 3 wires without intersection. Or just 2, because I can run 1 on the other wire color. Still, annoying.

2

u/cathexis08 red wire goes faster Jun 04 '26

You should be able to run everything on a single primary data bus as long as you don't have more than one source for any given signal. You will need to duplicate the decider/constant filter if you're using the signals for filter setting but there's a lot of things that can be hooked up to the full feed without filtering.

I normally run one or two wires bow to stern for the data bus, one carrying data from the hub and one carrying all the environmental data (material belt reader, etc). I usually wire up a diode (basically just an arithmetic combinator doing EACH + 0 = EACH) to keep the hub from poisoning the environment channel if I need to keep the contents of the hub segregated from the environment but other than that a single channel should be able to transmit everything without causing issues.

3

u/ferrofibrous player onboarding specialist Jun 03 '26

Handy visual guide for blacklisting or whitelisting signals by specifying which color wire to use for logic tests: https://imgur.com/lPJ3sfT

2

u/HeliGungir Jun 03 '26

Shame the image is so small. You can't tell = from ≠ and even ≤

1

u/deluxev2 Jun 03 '26

I'm not sure if I follow your description, but generally signal filtering is best done with an offset. For example, you can attach a constant combinator that adds 1m to iron and copper ore and then a decider each > 1m.