on_recipe_successfully_finished event

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
nullium21
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Sep 25, 2021 7:57 am
Contact:

on_recipe_successfully_finished event

Post by nullium21 »

Asking for a recipe called "on_recipe_successfully_finished": triggered when an entity has finished crafting a recipe AND has outputted a result (for probability-based recipes).
Must be filterable by entity type/name and recipe name/category.
Should probably be opt-in like on_entity_destroyed is: LuaBootstrap.register_on_entity_destroyed.

I need this to avoid checking every single crafter every tick ;) jk, i just want to disable a recipe once it's been crafted.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: on_recipe_successfully_finished event

Post by Silari »

Already been asked before and told no due to performance hit: viewtopic.php?f=28&t=47728&p=275519&hil ... te#p275519 though maybe using a registration system would help. Requiring a result was output seems a pointless thing to enforce since it'd be much better to simply include the results in the event, and allow setting a filter like other events - it wouldn't help the performance impact and would be more useful since people may want to know if a recipe output nothing.

And asked before with no reply: viewtopic.php?f=28&t=44269&p=256630&hil ... te#p256630

Both those threads are pretty old. Thought I remembered a more recent one but can't find it.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: on_recipe_successfully_finished event

Post by quyxkh »

You can shut off the on_tick hook when it completes, since this is by definition a one-shot cost this will be *vastly* cheaper than hooking every single recipe completion.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: on_recipe_successfully_finished event

Post by DaveMcW »

Here is a funny hack.

Use an inserter to remove the item. Wire the inserter to activate a mining drill. Use the mining drill to deplete a resource patch, which triggers the on_resource_depleted event.

Obviously everything in this contraption should be invisible and inside the area of the original assembling machine.

nullium21
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sat Sep 25, 2021 7:57 am
Contact:

Re: on_recipe_successfully_finished event

Post by nullium21 »

quyxkh wrote:
Sat Sep 25, 2021 8:58 pm
You can shut off the on_tick hook when it completes, since this is by definition a one-shot cost this will be *vastly* cheaper than hooking every single recipe completion.
i wanted this entity to be reusable but this sounds reasonable too. i could even disable both the entity and the recipe... thanks!
DaveMcW wrote:
Sat Sep 25, 2021 11:01 pm
Here is a funny hack.

Use an inserter to remove the item. Wire the inserter to activate a mining drill. Use the mining drill to deplete a resource patch, which triggers the on_resource_depleted event.

Obviously everything in this contraption should be invisible and inside the area of the original assembling machine.
wow, it must be quite difficult to set up... i mean, it's at least 4 entities. but it *is* a funny hack!
Silari wrote: Requiring a result was output seems a pointless thing to enforce since it'd be much better to simply include the results in the event, and allow setting a filter like other events - it wouldn't help the performance impact and would be more useful since people may want to know if a recipe output nothing.
yeah, i was only thinking about my usecase. this could easily be a flag in the filter.
Silari wrote: Already been asked before and told no due to performance hit: viewtopic.php?f=28&t=47728&p=275519&hil ... te#p275519
Silari wrote: And asked before with no reply: viewtopic.php?f=28&t=44269&p=256630&hil ... te#p256630
hm, i didn't see those threads...

about the performance hit, that was the reason i suggested registering specific entities for it.

quyxkh
Smart Inserter
Smart Inserter
Posts: 1028
Joined: Sun May 08, 2016 9:01 am
Contact:

Re: on_recipe_successfully_finished event

Post by quyxkh »

Thinking out loud here, you could keep the per-tick overhead down to checking each player, look at the recipe of anything they've got selected, then only watch the devices that change to that recipe. Not sure what other events you'd have to watch, on_settings_pasted and on_x_built_entity for blueprints and such I suppose.

Post Reply

Return to “Modding interface requests”