Event for machine crafting complete

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
i142857
Manual Inserter
Manual Inserter
Posts: 1
Joined: Mon Nov 04, 2024 9:56 am
Contact:

Event for machine crafting complete

Post by i142857 »

In my mod, I would like to react to a (custom) assembling-machine finishing a craft. As far as I can tell, there is no way to do this short of reading LuaEntity.crafting_progress or LuaEntity.products_finished on every tick. I was hoping for something better or more efficient.

This was requested a long time ago but it never got a definitive answer (viewtopic.php?t=44269).

In 2.0 assembly machines actually have this feature for logistic networks, where they send a 1-tick signal on craft complete. So it kind of feels like mods/scripts are less powerful in this regard than the logistic network, which seems the wrong way around :). So what do you think?

For more on my use case: I'm (ab)using assembly-machines as pay gates of sorts with fixed, one-time "unlock" recipes with no results. Basically, pay this cost for an effect (that is often not revealed in advance). An assembling-machine gives me a nice UI for free which documents the cost as you hover the recipe name, provides slots to put the items in (even partially) and the player inventory to grab them from and can be automated nicely if you want to deliver the goods via belts and inserters. It's a much nicer experience than, say, a container that you're supposed to put the price in. I just need to know when they finish a craft.

Thank you for your consideration!
ahicks
Inserter
Inserter
Posts: 24
Joined: Sat Jul 13, 2024 10:45 pm
Contact:

Re: Event for machine crafting complete

Post by ahicks »

Factorio 2.0 now supports multiple crafts per tick. I think you're also implicitly asking for a filter. Otherwise you're going to get like thousands per second.

(I'm not official, just skimming these because mostly if it's an API request we probably need it for our use case).
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 533
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Event for machine crafting complete

Post by Silari »

There was a more clear no response in viewtopic.php?f=28&t=47728 though even that one wasn't moved to Won't Implement.
User avatar
micromario
Fast Inserter
Fast Inserter
Posts: 109
Joined: Thu Apr 05, 2018 11:53 am
Contact:

Re: Event for machine crafting complete

Post by micromario »

You should add a dummy item to your recipe with a spoil trigger result of 1 ticks.
Then use this trigger result to get the event of the crafting machine completing.
Post Reply

Return to “Modding interface requests”