Page 1 of 1

Method to clone/duplicate an entity

Posted: Fri May 12, 2017 5:34 pm
by sparr
I would like for LuaEntity.clone() to exist or for LuaSurface.create_entity(LuaEntity) to create a copy of the entity in question or some other similar functionality.

Re: Method to clone/duplicate an entity

Posted: Fri May 12, 2017 6:03 pm
by Rseding91
There exists no such logic in the game. The best you can get is to create an entity of the same name and then use copy_settings to copy the settings from the old entity.

Re: Method to clone/duplicate an entity

Posted: Fri May 12, 2017 6:23 pm
by sparr
Rseding91 wrote:There exists no such logic in the game. The best you can get is to create an entity of the same name and then use copy_settings to copy the settings from the old entity.
That's unfortunate. That leaves a lot of un-copyable attributes :(

Re: Method to clone/duplicate an entity

Posted: Fri May 12, 2017 6:43 pm
by Rseding91
sparr wrote:
Rseding91 wrote:There exists no such logic in the game. The best you can get is to create an entity of the same name and then use copy_settings to copy the settings from the old entity.
That's unfortunate. That leaves a lot of un-copyable attributes :(
That's how it works. The game never needs to clone things to that extent so we never built a system to do it. You'll need to build your own if you want such a thing.

Re: Method to clone/duplicate an entity

Posted: Wed Jan 09, 2019 5:28 am
by sparr
Looks like LuaEntity::clone() is going into 0.17. Hooray!