Page 1 of 1

[Suggestion] Changes to auto recycle

Posted: Tue Oct 14, 2025 4:02 am
by SHADOW13
From what I understand, recipes come, by default with "auto-recycle" feature - allowing the items to be recycled back.
There is a problem with current implementation: the "last" recycling recipe works(?)
if another mod adds new recipe for existing item - it overwrites existing recycling setup - breaking existing factories - by default

For example, based on Fundryu mod:
- it introduces new Fundryu-specific recipe: Iron ore -> Iron gear wheel
- auto-recycle "creates" recycle recipe: Iron gear wheel -> Iron ore
- auto-recycle recipe from the mod overrides default Factorio one: Iron gear wheel -> Iron plate
- this in turn breaks existing recycling factories in the game (especially important in Fulgora setups since it's full of gears)

Yes, one can always redo whole base setup when installing a mod but I think allowing override of existing recipes BY DEFAULT is a wrong way around it.
It would be better to enforce compatibility by default.

I know you can use RecipePrototype's "auto-recycle=false", however in my opinion existing (recycling) recipes should NOT be overridden by default, unless mod specifically requests it.

Suggestion:
- ONLY allow auto-recycle of items that do NOT have a recycle setup yet
- keep auto-recycle=true by default with small(?) change that this applies to items that do not have a recycling setup/recipe yet
-- ie. first recycle recipe applies (ie. Factorio game always first)
- auto-recycle=false would mean that the recipe does not have recycled option automatically, no change here
- mods can still override auto-recycling but have to declare intent to force their (auto) recycle recipe of specific items (ie. introduce auto-recycle=force)

Re: [Suggestion] Changes to auto recycle

Posted: Tue Oct 14, 2025 1:26 pm
by meifray
I don't think so, auto_barrel and auto_recycle is documented well in vanilla game and the modder really should watch out what then done with recipes.

And if modder some how add new iron-gear-wheel recipe, it probablly should mean a better recipe which should be the recipe that more approach supposed full ratio instead of old inefficient one, thus in a sense, current implementation is perfectly aligented to this change.

If it was me, I will just crash the engine if game found two or more candidate of recycling recipe to the same item.
and maybe, instead of boolean value in recipe, I would make it a recipeID in each item prototype, but by the fact item prototype has many subtypes it might be painful.

Re: [Suggestion] Changes to auto recycle

Posted: Tue Oct 14, 2025 8:59 pm
by SHADOW13
meifray wrote: Tue Oct 14, 2025 1:26 pm I don't think so, auto_barrel and auto_recycle is documented well in vanilla game and the modder really should watch out what then done with recipes.

And if modder some how add new iron-gear-wheel recipe, it probablly should mean a better recipe which should be the recipe that more approach supposed full ratio instead of old inefficient one, thus in a sense, current implementation is perfectly aligented to this change.

If it was me, I will just crash the engine if game found two or more candidate of recycling recipe to the same item.
and maybe, instead of boolean value in recipe, I would make it a recipeID in each item prototype, but by the fact item prototype has many subtypes it might be painful.
this is not about adding or not new recipes - it's about breaking existing saves by default,
the change in auto-recycle pretty much retains the existing setup with exception of not overriding anything existing UNLESS modder intended on it

that's should be approach taken, with it everyone wins: player not breaking the existing saves, modder to have the mod working as intended

Re: [Suggestion] Changes to auto recycle

Posted: Tue Oct 14, 2025 9:16 pm
by PennyJim
I personally just wish we could somehow provide/change the second argument to this function call
https://github.com/wube/factorio-data/b ... tes.lua#L5
That way if you want non-overwriting behavior you can just add it to your `can_recycle` function.

At the same time, I'd want the default_can_recycle to be accessible from outside the file (put it in the library) so you can call it so your custom behavior can build upon it.
One way to be able to change the can_recycle function the main recycling pass does is to be able to just change the default, but I'm not sure I like that solution over specifically changing what that call uses.

Re: [Suggestion] Changes to auto recycle

Posted: Tue Oct 14, 2025 9:38 pm
by disilon@gmail.com
As modder you can change recycling recipe generation yourself however you want.
It's not done in game engine, everything (except using specific recipe category) is done in lua.

Re: [Suggestion] Changes to auto recycle

Posted: Tue Oct 14, 2025 10:57 pm
by PennyJim
disilon@gmail.com wrote: Tue Oct 14, 2025 9:38 pm As modder you can change recycling recipe generation yourself however you want.
It's not done in game engine, everything (except using specific recipe category) is done in lua.
While it is in Lua, it's not as if you can just change the code from another mod.
You can undo said changes, but we want to change how it does it in the first place so we don't have to

Also, I'm not sure there's anything specific about that recipe category that's engine specific. There's the utility constant that controls which categories gets put into the recycling section of factoriopedia.