LuaFlowStatistic for Recipes

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Quorken
Inserter
Inserter
Posts: 22
Joined: Mon Aug 18, 2025 3:53 pm
Contact:

LuaFlowStatistic for Recipes

Post by Quorken »

Idea
Per the title, the game would track statistics for each recipe. This could also be displayed in the game, or kept internal. Specifically, this would track n_batches_produced for each recipe, which would be how many output batches have been produced for a given recipe. So it would include outputs from productivity.

Ideally, it would also track n_ingredient_batches for each recipe - how many batches of ingredients has actually been consumed for each recipe. Personally, I don't have a use for this statistic (yet, anyways), but if you're already adding a statistic for n_product_batches, it probably wouldn't be much harder?
Use case
I have a mod idea that would make recycling better able to handle items with multiple distinct recipes. Essentially, it would have one recycling recipe for each recipe that can produce an item, and would only enable the recycling recipe if more has been produced with the production recipe than has been recycled.

I.e. recyclingRecipe.enabled = n_produced_recipe > n_consumed_recycling

Of course, the # of a recipe that's been performed would have to be multiplied by the # of the relevant item that's produced per cycle of the recipe, but that's fairly straightforward. Recycling (w/o mods) does not take productivity modules, so you can assume n_input_batches == n_recipe_cycles.

Currently, if I wanted such a statistic, I would need to iterate over all production machines every X ticks, look at what recipe each one has set and how many cycles it has completed since the last check. This would be both (potentially) slow, and inaccurate.

There would still be potential issues - planet-specific recipes for items, for example, which might never be produced on another planet. You probably don't want to recycle circuits on Fulgora and end up with tungsten plates, or something. But I think it's much easier to track cargo pods (since there are associated events), than to also iterate over all machine.

Edit:
Preferably, this statistic would also be planet-specific, like items and fluids already are.

For quality - the statistic would be quality-specific, as well; if a recipe produces a higher tier of quality, that would be counted under that higher quality's entry for that recipe. So if a recipe using common ingredients produces a legendary item, the legendary result would be counted for the legendary version of the recipe.

Edit(2):
I remembered that recipes are force-global. So I would need to add planet-specific versions of each recycling recipe, as well...(using surface conditions?)
Rseding91
Factorio Staff
Factorio Staff
Posts: 16124
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaFlowStatistic for Recipes

Post by Rseding91 »

flow statistics are a large complex and overall slow structure in the game. Having one exist for every recipe for every force for every planet would add a *ton* of overhead.
If you want to get ahold of me I'm almost always on Discord.
Quorken
Inserter
Inserter
Posts: 22
Joined: Mon Aug 18, 2025 3:53 pm
Contact:

Re: LuaFlowStatistic for Recipes

Post by Quorken »

Huh. I'm so used to the production graphs being in the game, I've never really thought of them as having a significant cost.

Would just keeping the total batches produced (i.e. not keeping the history or anything else) per recipe/force/surface be manageable, or would even that add too much overhead?

I'm wondering if it could be toggled on with a data-stage flag; so the game isn't impacted by it unless a mod explicitly requests it be activated.

But there's also a matter of implementation complexity; I have no idea how many parts of the code would need modifying to implement this correctly.
Post Reply

Return to “Modding interface requests”