Page 1 of 1

How can I keep items?

Posted: Mon Nov 07, 2016 12:02 pm
by sore68
Hi~

I create turret mod and entity is add add add...

And I have to change the name to manage.
But if I change entity name, It is delete.

I want some way, Even if change entity name, maintain entity and renewal new name.

Is this possible?

Re: How can I keep items?

Posted: Mon Nov 07, 2016 6:03 pm
by Rseding91
Yes, you want to use an entity migration script. You can look at how we do it in the core mod migrations folder.

Specifically json migrations: http://lua-api.factorio.com/latest/Migrations.html

Re: How can I keep items?

Posted: Tue Nov 08, 2016 3:50 am
by sore68
Rseding91 wrote:Yes, you want to use an entity migration script. You can look at how we do it in the core mod migrations folder.

Specifically json migrations: http://lua-api.factorio.com/latest/Migrations.html

Oh Thank you!!

But can I have some example??



I change prototype/entity name
"rapid-cannon-turret" -> "cannon-turret-mk1"

and add migrations

Code: Select all

game.reload_script()

{
	"entity":
	[
		["rapid-cannon-turret", "cannon-turret-mk1"]
	],
	"item":
	[
		["rapid-cannon-turret", "cannon-turret-mk1"]
	]
}
but don't load save game

and this message
message

Did I make a mistake?

Re: How can I keep items?

Posted: Tue Nov 08, 2016 5:49 am
by sore68
Oh It work!!

not lua.. just json :D

and type only

Code: Select all

{
  "item":
  [
    ["rapid-cannon-turret", "cannon-turret-mk1"]
  ] 
}
...