Page 1 of 1

[SOLVED] Missing new added items after updating mod

Posted: Thu Sep 19, 2019 3:50 pm
by Cobaltur
Hi all,

I need some hints for which keyword I have to look into.

Background:
I updated my first mod in the last days MathCoProcessor
I had a sandoxbox save but also another player has observed the behavior in the normal game.

Steps I have done:
- The recipe in my mod 0.17.0 unlocked 3 items
- Then I added more items to the same recipe
- The uploaded mod 0.17.1 recipe should have 7 items but still only the old 3 items can be crafted. In the tech window 7 items are shown.

Workaround:
resetting the research and re-unlock all technologies bring all items in the craft window.

Must be there an update script within the mod?

Thx in advance

Re: Missing new added items after updating mod

Posted: Fri Sep 20, 2019 7:16 am
by Pi-C
Cobaltur wrote:
Thu Sep 19, 2019 3:50 pm
Workaround:
resetting the research and re-unlock all technologies bring all items in the craft window.

Must be there an update script within the mod?
You're on the right track, have a look at migration scripts! Your script could be as simple as this:

Code: Select all

for _, force in pairs(game.forces) do
    force.reset_recipes()
    force.reset_technologies()
end

Re: Missing new added items after updating mod

Posted: Fri Sep 20, 2019 7:58 am
by Cobaltur
thanks a lot.


my migrations script

Code: Select all

for index, force in pairs(game.forces) do
  local technologies = force.technologies
  local recipes = force.recipes

   if technologies["math-combinators-2"].researched then
	local names = {"avg-combinator","med-combinator", "sum-combinator", "cnt-combinator" }
	for i, name in ipairs(names) do
		recipes[name].enabled = true
		recipes[name].reload()
	end	
  end
end

Re: Missing new added items after updating mod

Posted: Fri Sep 20, 2019 8:07 am
by Pi-C
Cobaltur wrote:
Fri Sep 20, 2019 7:58 am
thanks a lot.
You're welcome!
my migrations script
I can't see anything wrong with it on a quick glance-over, perhaps somebody else will … :-)

Re: [SOLVED] Missing new added items after updating mod

Posted: Tue Sep 24, 2019 10:20 am
by darkfrei
I don't like the reset_recipes and reset_technologies, they are disable already enabled recipes.

Re: [SOLVED] Missing new added items after updating mod

Posted: Tue Sep 24, 2019 11:02 am
by Pi-C
darkfrei wrote:
Tue Sep 24, 2019 10:20 am
I don't like the reset_recipes and reset_technologies, they are disable already enabled recipes.
Are you sure? I think I tried it and kept researched recipes. May be that was with Creative Mod enabled (can't tell exactly anymore), but I remember being wary of X_reset() because all changes would be lost while it actually reloaded everything (including changes to recipes/technologies by mods).

Needless to say, reloading just specific recipies is more accurate then a global reset -- my example was meant to show the easiest way (from a modder's perspective -- writing a single command is easier than iterating through a list of recipes and executing a command on each entry), which also happens to be the most radical way. :-D

Re: [SOLVED] Missing new added items after updating mod

Posted: Tue Sep 24, 2019 11:25 am
by eradicator
Pi-C wrote:
Tue Sep 24, 2019 11:02 am
darkfrei wrote:
Tue Sep 24, 2019 10:20 am
I don't like the reset_recipes and reset_technologies, they are disable already enabled recipes.
Are you sure? I think I tried it and kept researched recipes.
They're sledgehammers that will destroy all "manual" changes made by mods, like unlocking recipes for exploring the map (like in seablock etc). BUT, they exist in the API. They're easy to use. And lots of mods do use them, and i think even vanilla uses them sometimes. So as a mod author you can not rely on them not being called. If a mod wants to do manual changes there's no way around dealing with the fallout of those sledgehammers.

Re: [SOLVED] Missing new added items after updating mod

Posted: Tue Sep 24, 2019 11:31 am
by BlueTemplar
Is there no way for these mods to extend these commands to include manual changes ?

Re: [SOLVED] Missing new added items after updating mod

Posted: Tue Sep 24, 2019 12:58 pm
by darkfrei
BlueTemplar wrote:
Tue Sep 24, 2019 11:31 am
Is there no way for these mods to extend these commands to include manual changes ?
Enabling hidden technologies?

Re: [SOLVED] Missing new added items after updating mod

Posted: Mon Sep 30, 2019 8:48 am
by BlueTemplar
Relevant discussion about this category of issue in this thread :
viewtopic.php?p=454026#p454026