Closed embermctillhawk closed 4 years ago
Thanks for the report.
The mod does not call reset_technology_effects(). Once upon a time it did, I don't remember when I removed it. I note the latest code (v0.18.2) still makes reference to it, but it is not called. Instead, in control.lua on_init and on_configuration_changed() events, the mod enables the reverse recipe (the Recycling recipe) for every recipe that is itself enabled.
At https://lua-api.factorio.com/latest/LuaForce.html#LuaForce.reset_technologies reset_technology_effects() is documented as
Reapplies all possible research effects, including unlocked recipes. Any custom changes are lost. Preserves research state of technologies.
I don't see therefore why any starter vanilla items should not be recyclable. If the vanilla recipe is enabled, then my code on_init and on_configuration_changed handlers enables the reverse_recipe for every recipe that is enabled.
Update: The patch that I wrote into bobplates and tested a dozen times has now stopped working for no apparent reason. The only information that I can still give you is that it's specifically bobplates that this is happening with, and that my computer is cursed.
Hmm. See https://github.com/DRY411S/Recycling-Machines/issues/43
It was bob's plates use of reset _technology_effects that caused me to make significant changes to this mod, to add all recycling recipes to technologies, so that his call to reset_technology_effects() did not blat my recipes.
I can see that the recycling of vanilla recipes that are available at start of game is not possible when bobplates is present. I'm not ready to accept that this is a bug in my mod.
With just my mod enabled at start of game, the items are recyclable.
With both mods enabled at start of game, the items are recyclable.
With my mod enabled at start of game, then bobs plate added, the items are NOT recyclable but the on_configuration_changed code in my mod DOES enable them
With bobplates enabled at start of game, then my mod added, the items are NOT recyclable but the on_init AND on_configuration_changed code in my mod DOES enable them
Confirmed as a bug in my mod.
I think I figured it out! According to Data.raw
, all the starter recipes don't have an enabled entry.
Modded starter recipes usually specify enabled=true
for their starter recipes, but it looks like the vanilla starter recipes just don't specify enabled=true
or enabled=false
, so in the code when it checks for v.enabled==true
you get nil==true
which is false, so it doesn't know to re-enable it.
Hmm. Or not. Or maybe my computer actually is just cursed.
I have diagnosed the cause and fixed it. It will be in the next release.
You're right about the starter recipes having enabled = nil.
The enablement of the starter recipes is achieved by the game 'soft researching' the "basic-foo" technologies (in the
On the other hand, my mod was creating technology-effects for the recycling recipes for those 'basic-foo' starter recipes with enabled=false. My mod was enabling the recycling recipes using the on_configuration_changed event. Bob's plates on_configuration_changed event was being called by the game after my mod's code and calls reset_technology_effects() thus disabling the starter recycling recipes again.
This appears to be an issue with technology prototypes that were defined by the devs but are 'unresearchable'. Enabled = false is change to enabled = true for researchable technologies, but not these starter technologies. (In my view, this is a bug in the vanilla product).
Modifying my mod code to set enabled = nil for startup recycling recipes has cured the problem.
The reason I was doing it the way I was, is because the starter recycling recipes were appearing in the player's crafting menu BEFORE recycling machines had been researched! Now that recycling recipes no longer appear in player crafting menus, I can implement this fix.
Yes, this is similar to previous issues. I have done the groundwork and diagnosed the specific cause, however.
If any mod calls
reset_technology_effects()
in its owncontrol.lua
for every force from anon_configuration_changed
event then any vanilla starting crafts will no longer be recycleable. Modded starting crafts appear to survive without issue.Reproduction steps:
Locally altering the other mod to check if the
ZRecycling
global exists and if it does then skipping its ownreset_technology_effects()
code does cause the issue to disappear, or simply starting a new save file for every configuration change is also a workaround, or using the console to re-enable the desired recipes until the next configuration change.If it's still a wontfix then alright, but I figured you ought to hear about my discovery.
EDIT: I created a stub mod which has only the
reset_technology_effects()
code and it doesn't break anything. I guess I'll go bother Bob about it then.