![Laughing :lol:](./images/smilies/icon_lol.gif)
I was wondering if someone could give me information on writing a migration script so I can reload recipies into peoples save games?
I can find scraps of information but nothing concise enough to follow to create one.
![Neutral :|](./images/smilies/icon_neutral.gif)
Code: Select all
game.onload(function()
YOUR CODE HERE, WITH THE CHECKS?
end
)
Code: Select all
remote.addinterface("YOUR_MOD_NAME", {
checkunlocks = function(){
YOUR MIGRATION CODE HERE
}
})
Code: Select all
remote.call("YOUR_MOD_NAME", "checkunlocks")
Code: Select all
{
"first-type": --as far as I know the types are "entity", "item", and "tile"
[
["first-old-name", "first-new-name"],
... (other migrations here)
["last-old-name", "last-new-name"]
],
... --other type(s) here
"last-type":
[
["first-old-name", "first-new-name"],
... (other migrations here)
["last-old-name", "last-new-name"]
]
}
Ok, cool. Is that mean, if i just rename migration file instead of creating new one, game will execute it anyway?FreeER wrote:Migration scripts, from my understanding, are 'marked' (word choice?) in the save after they've been applied, and when a save is loaded Factorio checks if there are any existing migration scripts that are have not yet been 'marked' in the save, if so they are applied and marked during the loading of the save (or prior, not entirely sure which but it doesn't really matter to us lol).
...
Basically, though you will have to restart Factorio before it will be seen. Be aware however that if you were sharing a mod you'd really want to create new ones so that even if people didn't update for two or three mod versions they'd have the needed migration files when they didReygan wrote:Ok, cool. Is that mean, if i just rename migration file instead of creating new one, game will execute it anyway?
Of course, but at the first i have to post at least the first version of my modFreeER wrote:Basically, though you will have to restart Factorio before it will be seen. Be aware however that if you were sharing a mod you'd really want to create new ones so that even if people didn't update for two or three mod versions they'd have the needed migration files when they didReygan wrote:Ok, cool. Is that mean, if i just rename migration file instead of creating new one, game will execute it anyway?
Well, then if mod have more then one migration script, which one will execute? Or in which order, if alltogether?FreeER wrote:Basically, though you will have to restart Factorio before it will be seen. Be aware however that if you were sharing a mod you'd really want to create new ones so that even if people didn't update for two or three mod versions they'd have the needed migration files when they didReygan wrote:Ok, cool. Is that mean, if i just rename migration file instead of creating new one, game will execute it anyway?
All of the migrations that have not already been marked in the save will run (sequentially I believe)...as for the order, I'm not 100% sure right now, but I would assume based on the creation date of the script.Reygan wrote: Well, then if mod have more then one migration script, which one will execute? Or in which order, if alltogether?
Or in aphabet order, may be.FreeER wrote:All of the migrations that have not already been marked in the save will run (sequentially I believe)...as for the order, I'm not 100% sure right now, but I would assume based on the creation date of the script.Reygan wrote: Well, then if mod have more then one migration script, which one will execute? Or in which order, if alltogether?
still a big issue for meSpeedyBrain wrote:What can I do when an entity type was replaced with another type.
E.g.
Old:
type=container
name=example
New:
type=cargo-wagon
name=example
If you try to load a map where an entity {container,example} is placed on the map the game will say that the map is corrupted.
I couldn't find a way to delete this entity or tell the game that the type changed....
sorry, see my mod, v 0.3.0SpeedyBrain wrote:still a big issue for me
Anyone got a solution?
Code: Select all
{
"entity":
[
["cursed-exchange-1", "cursed-exchange"]
],
"item":
[
["cursed-exchange-1", "cursed-exchange"]
]
}
Doesn't work for me because I'm not changing the name! I am changing the entity type!L0771 wrote:sorry, see my mod, v 0.3.0SpeedyBrain wrote:still a big issue for me
Anyone got a solution?cursed-exchange-1 is the old entity and old item.Code: Select all
{ "entity": [ ["cursed-exchange-1", "cursed-exchange"] ], "item": [ ["cursed-exchange-1", "cursed-exchange"] ] }
you can change the name and let localization make it seem the same nameSpeedyBrain wrote:Doesn't work for me because I'm not changing the name! I am changing the entity type!L0771 wrote:sorry, see my mod, v 0.3.0SpeedyBrain wrote:still a big issue for me
Anyone got a solution?cursed-exchange-1 is the old entity and old item.Code: Select all
{ "entity": [ ["cursed-exchange-1", "cursed-exchange"] ], "item": [ ["cursed-exchange-1", "cursed-exchange"] ] }
that would remove the old entities and I don't want that. (they are quite expensive to makeratchetfreak wrote:you can change the name and let localization make it seem the same nameSpeedyBrain wrote:Doesn't work for me because I'm not changing the name! I am changing the entity type!L0771 wrote:sorry, see my mod, v 0.3.0SpeedyBrain wrote:still a big issue for me
Anyone got a solution?cursed-exchange-1 is the old entity and old item.Code: Select all
{ "entity": [ ["cursed-exchange-1", "cursed-exchange"] ], "item": [ ["cursed-exchange-1", "cursed-exchange"] ] }
The code don't uses the type of entity, is only "entity", isn't important if are a radar, pipe, boiler... is a entity...SpeedyBrain wrote:Doesn't work for me because I'm not changing the name! I am changing the entity type!
I'm going to do some testing in the next days...L0771 wrote:The code don't uses the type of entity, is only "entity", isn't important if are a radar, pipe, boiler... is a entity...SpeedyBrain wrote:Doesn't work for me because I'm not changing the name! I am changing the entity type!
But i don't know if it's true