
I need (or more precisely I want) to alter some base tech's prerequisites. I've tried to do it with this in my tech.lua:
Code: Select all
data.raw["technology"]["solar-energy"].prerequisites = {"optics", "advanced-electronics", "my-new-uber-tech"}
Code: Select all
data.raw["technology"]["solar-energy"].prerequisites = {"optics", "advanced-electronics", "my-new-uber-tech"}
It works fine in new games because there is no save with the old prototypes for a new gameForien wrote:and tech worked fine
If you're going to release the mod to other people, and want to allow people to use it with already started games without having to run the command in the console theirselves, then you can place it in the oninit event so that it is ran automatically for them. If you don't plan to release the mod then there's no real reason to place it in oninit (since any new game you make will not have the issue, as you've noticed).Forien wrote:But you say it's better to call "game.player.force.resettechnologies()" in control.lua on init event?
Then I'll also mention that if you added recipe unlocks (or removed them) then you'll also need to check in oninit whether the save already had those technologies unlockedForien wrote:I hope to release my mod soon, so any hints about things to do when releasing are welcome!
Code: Select all
local techname = game.player.force.technologies["tech-name"].researched
game.player.force.recipes["recipe-name"].enabled = techname
Code: Select all
game.player.force.resetrecipes()
game.player.force.resettechnologies()
Do they? I assumed that they wouldn't run for a new mod since they were intended for mod updates. From my understanding migrations are only run if they were added after the save was created (they're also 'saved' in the save, though by name only).Nova wrote:The migration file gets called every time you start an old save with a new mod
All true Nova, I just didn't realize that saves would recognize the migration files of a new mod as something that they should run since there is nothing from that mod yet to need migration. So, I thought that it'd need to be done during the initialization of the modNova wrote:Every save saves which migration file it already has processed. If you now add a new mod with a new migration file, the save sees "yes, that's a new migration file, i run that."
Migration files are (as far as i know) not run if you start a new map with some mods.
It does to an extent...mostly, I think, for dependencies (on other mods). If I recall correctly, not with migration files, it's based entirely on the name of the migration files. So when you release a new mod version and need to update something, by which I mean a change not new additions which should work fine without a migration, from the older version you just add a new migration file with a different name, if you look at data\base\migrations you'll see that the devs name theirs based on the date and mod version. For names of items changing you can use a .json migration file and the game will automatically change all of them (rather than you doing your best attempt and finding all of the items with lua and replacing them), you can see the format by opening the base game's migrations or (hopefully) reading this post I made about migrations some time ago.Forien wrote:Does the game recognizes mod version in some way
Code: Select all
base 2013-04-30_Factorio_0..4.0.lua base 2013-05-30_Factorio_0..5.0.lua base 2013-08-06_Factorio_0.6.0.lua base 2013-09-05_Factorio_0.7.0.lua base 2013-10-05_Factorio_0.7.1