Page 1 of 1

Update Entities/Items?

Posted: Tue Dec 19, 2017 8:22 pm
by Templarfreak
So, sometimes when Factorio updates and changes or removes entities or items, the game will automatically update those changed/removed things in your save for you. Is there a way to do this for a mod? Preferably without having to have a huge block of code? Maybe there's just an, "updateentities(x=a, y=b, z=c)" kind of thing?

(Also, is it possible to remove recipes that have already been unlocked that I don't want used anymore in case I may want to add them back in later?)

Re: Update Entities/Items?

Posted: Tue Dec 19, 2017 8:28 pm
by Bilka

Re: Update Entities/Items?

Posted: Tue Dec 19, 2017 8:43 pm
by Templarfreak
Thanks, but those examples are not totally clear,

Code: Select all

{
  "entity":
  [
    ["wall", "stone-wall"]
  ],
  "item":
  [
    ["wall", "stone-wall"]
  ]
}
Do I need to do something akin to how new Entities/recipes/technologies are added to the game via data:extend ? Or is this the only code needed? Does the Migrations folder just go right in the root of the mod or does it need to be in another folder?

EDIT: All of my initial assumptions were correct, you don't need more code than that and it just goes into the root of the folder, but you just gotta ask these things with a script language that you're new to just to be safe or it could cause hours of frustration.

Re: Update Entities/Items?

Posted: Wed Dec 20, 2017 9:19 am
by bobingabout
It is as simple as the example code you posted.

when a game is loaded, if wall exists, it will be replaced with stone-wall. in your case items and entities only, you could also add the recipe to that list too. It isn't needed, but if you don't, all machines with the recipe set already will lose that setting and be a blank machine waiting for you to tell it what to do. if you add the recipe to the migration, then the recipe will be change, and when you load the game, the existing machine will keep producing walls.

if a technology has it's internal name changed, you can do the same with that too.