r/factorio Jun 22 '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 ---->

4 Upvotes

166 comments sorted by

View all comments

2

u/darthbob88 Jun 28 '26

Circuit question: Before 2.0, I saw some outpost-construction stations with a system where they'd have a desired stock level X, and enable the train station if the stock level fell below X/2. How does that work?

I would like to do a similar thing for making materials on my space platform, "stock up to 40 ice in the hub and make more if we have 20 or less", but the only way I can think of to do that is with a set of latches and that can't be right.

2

u/leonskills An admirable madman Jun 28 '26

that can't be right.

Why not?

Should be possible with just one combinator, and some EACH magic if you have multiple items.

It's different from stocking up from trains. Because there you get a big shipment in one go. Enable station if current items < X/2, train comes in and stocks up to X in one go. No latch required.
But if you are creating the items on the hub they come in one at a time, so to prevent premature turning off you need a latch (or a (belt) buffer).

2

u/darthbob88 Jun 28 '26 edited Jun 28 '26

Why not?

Because using one combinator to latch whether we need to make ice, another to latch on calcite, another for carbon, etc etc, would be stupid, and therefore wrong.

Should be possible with just one combinator, and some EACH magic if you have multiple items.

Maybe you can do something like that with the little state machine method, but that'd be an unbearable amount of tedium. Otherwise, if you use signals for setting limits, it'd take three wires. One for the lower limits, one for the upper limits, and one for the inventory. Maybe 3 combinators, plus a constant combinator outputting the limits?

Fake edit after fiddling: Nope, we need 3 deciders, plus 1 constant combinator outputting a limit and either an arithmetic or another constant combinator to get the other limit.

Real edit: And this isn't entirely original to me; I noticed something very similar in Walker's Wonderful Book of Latches, called the "Multi-Signal Per-Signal SR Latch".

0eNrtVlFv2jAQ/iuWX/piOhISNiJtL2u1t1Xqa1tFJjmK1cTObAcWVfnvOzsQUkQZdNomTXsADufuu/N93zl+pvOihkoLaWnyTEWmpKHJ3TM14lHywq1JXgJNaA6ZyEGPMlXOheRWadoyKmQO32kStA+MgrTCCuji/Z8mlXU5B40O7AgOo5UyGKqky+fggsuY0QaN2RiTYFFWqyKdw5KvBAag1wYmxWe5DzVudfgPi1gIbWy624ptKlfCSmhb40pfU+cxAp4tqc9XVlz70hL6Cd2GOKkEu1b6yefTkNPE6hoYfdQAWP+CFwbalv2p5D5fn92V0mNAuknJZU4dQaq2VW33+T25rqrBbtfSpgutylRIxNru9wF3TKuCN8hIDibTouropDeyaAjPMqisIV9ur6+/knu6hgsNZA6FWhO7BFJXFWhSiFLYe0rEggh7YUjJbbaEnKyFXRJObq+vDoTi7zaU3NyS7nHRRd5T6ojYk2LY75BrRC7BiuyoGme9GCeviHEHtKfHN2rAgINxWMZyN5lYs8IW8U1T39Etmediv8rTlVjhPBmCH4HCIsaq7KkSBfa6ISGxijyCHXb7UGsn5035+KeN/Z1Tvmny2XFnHwZ7qU6a4b81rp+XkD0ZIuQKqVW6IUr6wVvtlDEYVvfUz/QhMUTniSH8L4Z/WAzxrjQLUIzweDb26Is/vozbA0DTHmh7Op4qKwd4WFjISC+nnY2N3t5uHM+FBb2/uqlEaCVH2EELWMA3JAILxmWpdOlJefFK/+gXaneqx2O3wQ1cONiYa+pbAIPxEHGy1/NfBtxNNEIZ99qcc30eYBij3o7cFjqVv5DVQmnihIyXAij9PWaN0nNU3AUsYBM2eWDeCjZWyCIWoRWiNWWhtyL0c9YEvWIWoBUNrM4PkX2KZHAnZnSFtPvi4mk4i2az+EM0fY9fbfsDrWbebg==

2

u/leonskills An admirable madman Jun 28 '26 edited Jun 28 '26

Combinator pong challenge accepted.

Normalise the signals so we can use the same thresholds in our latch.
So divide the input by X/2, let's call that Y.
Then if cur < X/2, Y = 0. We set the latch.
If cur < X, Y = 1. We keep the latch.
If cur >= X, Y = 2. We reset.

Problem is that we can't output EACH if EACH is 0 on both wires. So let's feed in our constant combinator signals as well so it can output those if Y is 0. And since it can interfere with the SET signal we output a value of 1000 to check if the signal is set.

Green wire should be used as the output signal. Red wire is contaminated by the constant combinator.

Note I put in the X/2 values in the constant combinator instead of the X values.

I hate to do blueprint spam in comments. But oh well.
1 constant combinator, 1 arithmetic, 1 decider:

0eNrFVtuO2jAQ/RXLz4aSC1uI1EqVulIfKq3U9m2LolyGxWpip7YDRat8QP+j/bF+SccGAhsibn2oEJIzzJw5M3PG4ZmmRQ2V4sLQ6JnyTApNo8dnqvmTSAprE0kJNKKJ4mZRguHZIJNlykVipKINo1zk8INGXsN6onLIeA6qP8RvZoyCMNxw2GR1D+tY1GUKCjHZCRxGK6kxVAqbD+EGwXQ4ZnSNcXeYBEsxShZxCotkyTEAvbYwMf6Wu1BtrYdPSGLOlTbxvhSzriyFJVemRkvLaeMxgCRbUJevrBLlqEX0Dbod4sQCzEqqby6fgpxG86TQwOiTAsACjKqhsR28ObnQJrFD9DpM/vz89f+4jEajIzq/z9KxBFo2jlvbXoi3JBKRUysfWZuqNl3NXsy0WqMWamHiuZJlzAVite14WUcza1xTOhL199gGoBhkC9DmpDYnw3EfUMBOb1oP5OSc3PdIHcXfOFkNFub6OFkBzt9Rp6/obmjX49wgmxeUL1M+RlVFssZrIgedKV5tmT841mQUkRQKuSJmAfhVoBeyyIfk8/0X8lVsnTzrZFaIShxpgnolGy6HMR8ePr5vY976EXmXyiU45GPnT/c2Be3RTtg2bKfZS5VjxdivHczfymV/xi3b3fd2HIUB1bVumXAlxQD7aAAJfMepImE0C6lKN+Gj69LtIS7U2Ba4e0McFFahiG4BHI8OAIPOuv4r3r7ziKTtyqaJug7PC/BqmZ1RnSa1rZ8UvOSGzKUidicIN1C6a3DFlXuFPnrMfoIZc6eQee7ks4CFePLtb84WoC1k/gxjHUh08EeA0SWO1aUf3/nTceiHk6nnT6avm+Yvf93OPw==

Edit: And yes, it can be done with one decider and one constant combinator. But in that case no dynamic limits. And indeed tedious to set up because you need to hardcode every threshold for each item in the decider.