[SOLVED] Missing new added items after updating mod

Place to get help with not working mods / modding interface.
Cobaltur
Long Handed Inserter
Long Handed Inserter
Posts: 51
Joined: Sat Sep 24, 2016 1:33 pm
Contact:

[SOLVED] Missing new added items after updating mod

Post 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
Last edited by Cobaltur on Fri Sep 20, 2019 7:59 am, edited 1 time in total.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1734
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Missing new added items after updating mod

Post 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
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Cobaltur
Long Handed Inserter
Long Handed Inserter
Posts: 51
Joined: Sat Sep 24, 2016 1:33 pm
Contact:

Re: Missing new added items after updating mod

Post 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
Pi-C
Smart Inserter
Smart Inserter
Posts: 1734
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Missing new added items after updating mod

Post 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 … :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei »

I don't like the reset_recipes and reset_technologies, they are disable already enabled recipes.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1734
Joined: Sun Oct 14, 2018 8:13 am
Contact:

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

Post 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
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5207
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3208
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

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

Post by BlueTemplar »

Is there no way for these mods to extend these commands to include manual changes ?
BobDiggity (mod-scenario-pack)
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post 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?
User avatar
BlueTemplar
Smart Inserter
Smart Inserter
Posts: 3208
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

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

Post by BlueTemplar »

Relevant discussion about this category of issue in this thread :
viewtopic.php?p=454026#p454026
BobDiggity (mod-scenario-pack)
Post Reply

Return to “Modding help”