Base recipe missing after mod removal

Place to get help with not working mods / modding interface.
Post Reply
User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Base recipe missing after mod removal

Post by PantherX »

Is it normal for recipes for base items to be missing when a mod (that removes these recipes) is removed from a save? Does the tech tree and recipes get refreshed when active mods change?

To give a specific example. I've got a mod that removes the item and recipe for Hazard concrete and changes the Concrete technology to also not unlock the Hazard variant. When the mod is removed from a save, although the hazard concrete item and recipe returns, the recipe is not enabled. reset_recipes and reset_technologies doesn't fix it either, and the only workaround I've found to re-enable the Hazard concrete recipe is to manually un-research the Concrete technology and research it again.

Is there a better way for me to handle this situation in the mod?

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Base recipe missing after mod removal

Post by Nexela »

Mods don't have an uninstall script. Recipes are unlocked via research. If you remove/change a recipe unlock you will need to unlock the recipe manually

/c game.player.force.recipes["recipe-name"].enabled = true

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5152
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Base recipe missing after mod removal

Post by Klonan »

Running

Code: Select all

/c game.player.force.reset_technology_effects()
Should re-enable all the recipes properly

User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Re: Base recipe missing after mod removal

Post by PantherX »

Thanks for the responses, it sounds like it's not something I can easily fix in the mod. It does raise another point though... If reset_technology_effects is a quick way to fix issues like this, is this something that the base game could automatically run when mods are removed? This would restore the game state no matter the situation.

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

*** UNTESTED ***

Instead of removing the item and its recipe, could you not instead just hide them?

http://lua-api.factorio.com/latest/LuaI ... e.has_flag
http://lua-api.factorio.com/latest/LuaR ... ype.hidden

Perhaps these properties would be reset with reset_recipes and reset_technologies?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Base recipe missing after mod removal

Post by bobingabout »

didn't one of the latest exprimentals force run "update_recipes" and "update_Technologies", basically what Klonan just said too on EVERY state change, as a way to make the mod settings system work for those with startup changes?

Therefore, in theory, removing any mod should now automatically run these scripts and fix this issues for you.
If that's not the case, let me know, but if you have the latest experimental, from what I understand the game SHOULD fix itself now.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

bobingabout wrote:didn't one of the latest exprimentals force run "update_recipes" and "update_Technologies", basically what Klonan just said too on EVERY state change, as a way to make the mod settings system work for those with startup changes?

Therefore, in theory, removing any mod should now automatically run these scripts and fix this issues for you.
If that's not the case, let me know, but if you have the latest experimental, from what I understand the game SHOULD fix itself now.
I believe that that has happened for a LONG time. Rsedling confirmed this to me in June 2016. viewtopic.php?f=25&t=26949&p=170831&hil ... pe#p170818

I think the issue here is that this mod author removes vanilla items completely, and not just the recipes. So when the mod is removed, the vanilla recipe is reset, the research for the item is reset, but the item itself is not recreated and thus not craftable.

Hence my suggestion that the mod tries just hiding the vanilla items rather than remove them. The mod is called Dectorio by the way. https://mods.factorio.com/?q=dectorio

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Base recipe missing after mod removal

Post by bobingabout »

This is true. I do actually disable recipe and remove from technology without removing the items.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Re: Base recipe missing after mod removal

Post by PantherX »

DRY411S wrote:I think the issue here is that this mod author removes vanilla items completely, and not just the recipes. So when the mod is removed, the vanilla recipe is reset, the research for the item is reset, but the item itself is not recreated and thus not craftable.

Hence my suggestion that the mod tries just hiding the vanilla items rather than remove them. The mod is called Dectorio by the way. https://mods.factorio.com/?q=dectorio
The mod hasn't removed the item definitions since 0.5.9 as this was causing issues with other mods that relied on the item being present. It currently does disable the recipes to prevent the item being crafted and it switches out the sprites on any existing vanilla hazard tiles to use the modded ones to maintain backwards compatibility in case the mod is later removed.

The issue here is that when the mod is removed, the vanilla recipes that are disabled (in this case, the hazard concrete) are not being re-enabled.

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

PantherX wrote:The mod hasn't removed the item definitions since 0.5.9 as this was causing issues with other mods that relied on the item being present. It currently does disable the recipes to prevent the item being crafted and it switches out the sprites on any existing vanilla hazard tiles to use the modded ones to maintain backwards compatibility in case the mod is later removed.

The issue here is that when the mod is removed, the vanilla recipes that are disabled (in this case, the hazard concrete) are not being re-enabled.
My apologies. My mod Remove Chemical Batteries (which removes the chemical plant recipe) displays the same behaviour which, frankly, was a surprise.

Looking at your code and mine, we both amend the technology effects for the vanilla item. Unless I'm having another brain fart, we seem to try to disable the technology in entirely opposite ways. You set the effects for concrete to be ONLY type = "unlock-recipe", where as I try to maintain all the effects EXCEPT unlock-recipe.
Your Code
My Code
You disable the hazard-concrete recipe, I merely hide the battery recipe.

Either way, we both lose the vanilla item in a saved game after disabling our mod. It appears that changing the technology 'effects' may be causing your (now OUR) issue. :(

User avatar
PantherX
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Sat Sep 03, 2016 6:26 am
Contact:

Re: Base recipe missing after mod removal

Post by PantherX »

DRY411S wrote:Either way, we both lose the vanilla item in a saved game after disabling our mod. It appears that changing the technology 'effects' may be causing your (now OUR) issue. :(
Well it would be interesting if that is indeed what is causing the problem. Strangely, though I've noticed that if you remove the mod and then go to the technology screen the hazard concrete does show correctly as being a recipe that is unlocked by Concrete, so the technology tree itself is resetting correctly and the item is being prototyped, it just doesn't seem to enable the recipe for crafting. I guess that makes sense since the mod, while installed and the tech is originally unlocked, tells it not to, but is there a better way we should be handling these tech changes to avoid this situation as we obviously can't fix it once the mod has already been deleted?

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

PantherX wrote:Well it would be interesting if that is indeed what is causing the problem. Strangely, though I've noticed that if you remove the mod and then go to the technology screen the hazard concrete does show correctly as being a recipe that is unlocked by Concrete, so the technology tree itself is resetting correctly and the item is being prototyped, it just doesn't seem to enable the recipe for crafting.<snip>
Rather than disabling the hazard-concrete recipe in your mod, have you instead trying merely hiding it (and the associated hazard-concrete item)?

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

DRY411S wrote:
PantherX wrote:Well it would be interesting if that is indeed what is causing the problem. Strangely, though I've noticed that if you remove the mod and then go to the technology screen the hazard concrete does show correctly as being a recipe that is unlocked by Concrete, so the technology tree itself is resetting correctly and the item is being prototyped, it just doesn't seem to enable the recipe for crafting.<snip>
Rather than disabling the hazard-concrete recipe in your mod, have you instead trying merely hiding it (and the associated hazard-concrete item)?
Let me answer my own question. It doesn't work. That was what I tried way back in factorio 0.12!

What we have in common is that we are removing a vanilla recipe from a vanilla technology with our mod, and then finding that while it does reappear in the technology tree when we remove our mod from a saved game, it is no longer craftable. This feels like a bug in the game to me, unless removing vanilla recipes from vanilla technology is verboten.

I'm going to raise a speculative bug report.

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

PantherX wrote: Strangely, though I've noticed that if you remove the mod and then go to the technology screen the hazard concrete does show correctly as being a recipe that is unlocked by Concrete, so the technology tree itself is resetting correctly and the item is being prototyped, it just doesn't seem to enable the recipe for crafting.
It appears to me that it DOES enable the item for crafting if you've used the mod, but haven't researched past the point that it would have been enabled for crafting.

Use mod, research past the concrete point, save, toggle the mod off. Hazard concrete reappears on research screen, but is not craftable.
Use mod, research to just before the concrete, save, toggle the mod off. Hazard concrete reappears on research screen. Research concrete. Hazard concrete IS craftable.

I've raised a bug report. viewtopic.php?t=51014

User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 727
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Base recipe missing after mod removal

Post by DRY411S »

OK, I think I may have a solution.

In control.lua define a function that handles the event 'on_research_finished'
In that function test for the event name being 'concrete' (or battery in my case)
Set the recipe for hazard concrete (or battery in my case) enabled as true.

So although you are hiding the hazard concrete and it's not in the technology.effects for concrete, you are unlocking the recipe.
This should mean that it becomes available again if you stop using the mod and revert to vanilla.

I use this technique to manually unlock recipes that aren't assigned to technology.effects in my Recycling Machines mod. In my case it's non-vanilla recipes, but I don't see why this won't work with vanilla.

Edit: I've posted a modified version of this proposed solution on your GitHub.

User avatar
ownlyme
Filter Inserter
Filter Inserter
Posts: 400
Joined: Thu Dec 21, 2017 8:02 am
Contact:

Re: Base recipe missing after mod removal

Post by ownlyme »

when you just set the recipe to ".hidden = true" in the data stage, it gets unlocked normally but doesn't show up in the technology or the player's recipes.
but when you disable the mod again, it shows up again
mods.factorio.com/user/ownlyme
My requests: uiAbove||Grenade arc||Blueprint allies||Creeps forget command/ don't get removed||Player Modifiers||textbox::selection||Better Heat IF||Singleplayer RCON||tank bug w/ min_range >= projectile_creation_distance

Post Reply

Return to “Modding help”