How can I keep items?

Place to get help with not working mods / modding interface.
Post Reply
sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

How can I keep items?

Post 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?

Rseding91
Factorio Staff
Factorio Staff
Posts: 13250
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: How can I keep items?

Post 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
If you want to get ahold of me I'm almost always on Discord.

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: How can I keep items?

Post 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?

sore68
Fast Inserter
Fast Inserter
Posts: 123
Joined: Mon May 02, 2016 8:39 am
Contact:

Re: How can I keep items?

Post by sore68 »

Oh It work!!

not lua.. just json :D

and type only

Code: Select all

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

Post Reply

Return to “Modding help”