[SOLVED] Missing new added items after updating mod

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

[SOLVED] Missing new added items after updating mod

Post by Cobaltur » Thu Sep 19, 2019 3:50 pm

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
Filter Inserter
Filter Inserter
Posts: 439
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Missing new added items after updating mod

Post by Pi-C » Fri Sep 20, 2019 7:16 am

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
Inserter
Inserter
Posts: 36
Joined: Sat Sep 24, 2016 1:33 pm
Contact:

Re: Missing new added items after updating mod

Post by Cobaltur » Fri Sep 20, 2019 7:58 am

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
Filter Inserter
Filter Inserter
Posts: 439
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Missing new added items after updating mod

Post by Pi-C » Fri Sep 20, 2019 8:07 am

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: 2290
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei » Tue Sep 24, 2019 10:20 am

I don't like the reset_recipes and reset_technologies, they are disable already enabled recipes.

Pi-C
Filter Inserter
Filter Inserter
Posts: 439
Joined: Sun Oct 14, 2018 8:13 am
Contact:

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

Post by Pi-C » 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. 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: 3744
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post by eradicator » Tue Sep 24, 2019 11:25 am

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: Hand Crank Generator, Screenshot Hotkey 2.0
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: 1812
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

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

Post by BlueTemplar » Tue Sep 24, 2019 11:31 am

Is there no way for these mods to extend these commands to include manual changes ?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2290
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei » Tue Sep 24, 2019 12:58 pm

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: 1812
Joined: Fri Jun 08, 2018 2:16 pm
Contact:

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

Post by BlueTemplar » Mon Sep 30, 2019 8:48 am

Relevant discussion about this category of issue in this thread :
viewtopic.php?p=454026#p454026

Post Reply

Return to “Modding help”

Who is online

Users browsing this forum: No registered users