Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Mon Feb 10, 2025 8:46 pm
by Milichip
TL;DR
This option on the right:
factorio_5VcFfyAbDx.png (247.96 KiB) Viewed 1044 times
What?
Add an option for assemblers to cancel their current craft and eject all items if the current "set recipe" signal has disappeared.
(if another DIFFERENT valid recipe signal is received, it will cancel the current recipe and switch to the new one immediately)
Why?
I am using the "set recipe" function to craft multiple rarities of the same item in a mall (e.g. normal electric pole AND uncommon electric pole) in one assembler. Switching the recipe automatically makes the inserters in front push items into it, however despite the fact that I pull the item as soon as I can from the item and remove the signal in only a few ticks, the assembler immediately starts another recipe, leading to an overproduction of 1 craft every single time.
The existing alternative solutions to fix this issue
(feeding an exact amount of items)
OR
(adding -1 to the amount desired after a delay once production starts where the delay would need to arrive after items are loaded but before the assembler finishes 1 craft)
OR
(adding -1 to the amount desired after the machine outputs it is working, except it's not -1 if the recipe crafts multiple of the item at a time e.g. 2 for belts)
are not the most engaging, in my opinion.
On top of that, having the additional control is relevant for very long recipes which is very relevant in cases where the player triggered something (i.e. pulled items from chest) and wants to immediately have feedback for that action (some machines immediately spitting out whatever they were doing to refill what the player demanded).
Also the extra flexibility would be relevant in mods.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Mon Feb 10, 2025 10:21 pm
by Muche
I wasn't able to reproduce your issue.
Yes, when the signal for recipe/item intended to be crafted changes/is removed, the machine finishes the current craft, but immediately after that it dumps everything into trash slots, it does not start another craft cycle.
My guess for you encountering it is due to combinator delays in circuit network, or some signals interference/leakage.
Have you experimented with your circuitry reacting to Read working signal?
For example, if it detects the machine started working, block the recipe signal, so the machine crafts for one cycle only.
Later it can react to Read recipe finished to set a recipe back.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Tue Feb 11, 2025 7:51 am
by boskid
No.
This was one of corner cases we considered and we will not be adding it. Reason is that at certain stages of game you may have >100% productivity and this option would allow to automate abuse of it making it an infinite productivity by cancelling craft when bonus progress finishes but before main cycle finishes.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Sat Feb 15, 2025 1:10 pm
by Milichip
Muche wrote: Mon Feb 10, 2025 10:21 pm
I wasn't able to reproduce your issue.
Yes, when the signal for recipe/item intended to be crafted changes/is removed, the machine finishes the current craft, but immediately after that it dumps everything into trash slots, it does not start another craft cycle.
My guess for you encountering it is due to combinator delays in circuit network, or some signals interference/leakage.
Have you experimented with your circuitry reacting to Read working signal?
For example, if it detects the machine started working, block the recipe signal, so the machine crafts for one cycle only.
Later it can react to Read recipe finished to set a recipe back.
I don't think there is a way for the machine to read its output -without- starting a new recipe.
The "fastest" thing I have found is this:
factorio_g07y98hTrw.png (79.05 KiB) Viewed 910 times
Which, as you can see, starts a craft immediately before it gets the chance to disable itself.
This was one of corner cases we considered and we will not be adding it. Reason is that at certain stages of game you may have >100% productivity and this option would allow to automate abuse of it making it an infinite productivity by cancelling craft when bonus progress finishes but before main cycle finishes.
That makes a lot of sense, though in that case would it be possible to just add a signal to tell the machine NOT to start a craft, even if it has ingredients available?
Currently, the problem with "set recipe" is that if you set it for one tick, it won't immediately start crafting until the items are loaded in, at which point the recipe can take as little as .5 seconds to complete, thus mandating the usage of a decider combinator if you want to craft an exact amount of items.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Sat Feb 15, 2025 2:40 pm
by Tertius
To craft exactly the desired amount, you need to change the recipe while the last craft is in progress.
The decision "I have enough in storage, change to other recipe" cannot be based on the amount of things you have, because of the latency of the decision process after a craft finished to provide a new recipe. This takes at least 1 tick (this isn't actually achievable, real process is at least 2-3 ticks), but in this 1 tick the machine has already started another production cycle if it has enough ingredients.
So you need to decide "I have enough after the current cycle" to have a few ticks to provide the new recipe while the last craft is in progress. If this craft finishes, and a new recipe is already in place in this moment, the machine ejects everything and switches to the new recipe.
How to decide "this is the last craft" is up to you. When I was at the same point as you, I decided it's not worth the trouble. Every single machine with recipe changing needs to be handled with this. But a few items overproduction is not really an issue. Instead of 100, it's 105. So what? I admit it's becoming unpleasant if you let the mall craft singular items like an expensive armor or an equipment module, but I simply let it go.
It's also kind of difficult to determine you have enough. How to count? It takes time to transport an item to your storage for counting. Inserter swing, robot transport, belt moving. And there's the quirk with the logistic network that robots will reserve/carry 4 items instead of just 1, and an item vanishes from counting temporarily while being carried by a robot. To be honest: not worth the hassle. I accept a little bit of overproduction.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Sat Feb 15, 2025 4:21 pm
by Muche
This contraption crafts exactly 10 iron gear wheels, one at a time, clearing the recipe and AM's inventory after each cycle.
It relies on input inserter swinging slower than the circuit network does the calculations.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Sat Feb 15, 2025 6:17 pm
by Milichip
Tertius wrote: Sat Feb 15, 2025 2:40 pm
To craft exactly the desired amount, you need to change the recipe while the last craft is in progress.
The decision "I have enough in storage, change to other recipe" cannot be based on the amount of things you have, because of the latency of the decision process after a craft finished to provide a new recipe. This takes at least 1 tick (this isn't actually achievable, real process is at least 2-3 ticks), but in this 1 tick the machine has already started another production cycle if it has enough ingredients.
So you need to decide "I have enough after the current cycle" to have a few ticks to provide the new recipe while the last craft is in progress. If this craft finishes, and a new recipe is already in place in this moment, the machine ejects everything and switches to the new recipe.
How to decide "this is the last craft" is up to you. When I was at the same point as you, I decided it's not worth the trouble. Every single machine with recipe changing needs to be handled with this. But a few items overproduction is not really an issue. Instead of 100, it's 105. So what? I admit it's becoming unpleasant if you let the mall craft singular items like an expensive armor or an equipment module, but I simply let it go.
It's also kind of difficult to determine you have enough. How to count? It takes time to transport an item to your storage for counting. Inserter swing, robot transport, belt moving. And there's the quirk with the logistic network that robots will reserve/carry 4 items instead of just 1, and an item vanishes from counting temporarily while being carried by a robot. To be honest: not worth the hassle. I accept a little bit of overproduction.
I'm aware of that. I can make it work no problem, I'm just saying it's not very engaging and I would like to have an additional tool at my disposal, because deciding "this is the last craft" for, conveyor belts (which craft 2 at a time) is a pain in the ass, since you "don't know" they are going to craft 2 unless you specify that information yourself. So adding 1 item to the signal while the machine is working is not good enough - for belts, you need to add 2.
I have also made another thread suggesting a way to read how many products a recipe will craft, however it is a lot more nuanced of an issue since it involves probabilistic crafts.
Regardless, this would be a neat tool. I believe extending the disabling behavior to have a checkbox that says "Finish current craft if disabled" would work great for this. Then you could just have it disable itself whenever it is working.
Re: Set assembler sub-toggle for "cancel craft" on set recipe
Posted: Wed Jun 04, 2025 5:11 pm
by brucemalt
Did you know that sending parts for space age space platforms is cheaper if you send the material and assemble in space? Well they are.
I would prefer to set a production target of x asteroid collectors, y crushers etc and exactly count how many should be produced. So being one off is a pretty big issue, but I guess this is already not going to be done for good reasons.