Changing entities types

Place to get help with not working mods / modding interface.
ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Changing entities types

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

SilverWarior
Filter Inserter
Filter Inserter
Posts: 559
Joined: Mon Mar 04, 2013 9:23 am
Contact:

Re: Changing entities types

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

ficolas
Smart Inserter
Smart Inserter
Posts: 1068
Joined: Sun Feb 24, 2013 10:24 am
Contact:

Re: Changing entities types

Post 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

kovarex
Factorio Staff
Factorio Staff
Posts: 8194
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: Changing entities types

Post 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).

Post Reply

Return to “Modding help”