Page 1 of 1

Changing entities types

Posted: Sat May 04, 2013 11:27 am
by ficolas
I changed all the underground mining drill entities in my mod, to be assembly machine instead of container, so I can make them use energy, but what I got is this:

entity underground-mining-drill saved as type container, but is now type assembly machine.

Is there any easy way to fix this without removing all the underground mining drills?

Re: Changing entities types

Posted: Sat May 04, 2013 12:18 pm
by SilverWarior
I'm not sure about this but I belive you would need to write some special script which would execute on savegame load one similar to those scripts used for loading savegames made with previous versions of Factorio.
So I suggest that you check those scripts to get the idea of what you need to do.

Re: Changing entities types

Posted: Sat May 04, 2013 1:00 pm
by ficolas
I could leave the old mining drill, and the new mining drill, and replace them on the startup, but I prefer to make it less messy

Re: Changing entities types

Posted: Sat May 04, 2013 1:02 pm
by kovarex
The entity can't just change the type, it would break the serialisation (every type loads different values).

The only solution I can think of is to make the new entity completely new and leave the old one there and then go through all old entities destroy them and place the new one instead.
This could be done in the migration script, so it is done only once per save and only for old saves (not new games).