Page 1 of 1

Making "fake single" entity from multi entities?

Posted: Sun Jan 22, 2023 8:35 am
by DemerNkardaz
I want to add to my mod high-tier structure that can and transfer and store the electricity, call it "substation facility".
But, it is impossible to apply multiple types to one entity, directly we can have only or electricity-pole or accumulator.

I thought about pasting two entity both from one item, but I don't think just add it to "place_result" will be works, and this need coordinates and removeablity of two spawned entities simultaneously to prevent item-entity duplicating "cheat".

What you thinks about this?

Re: Making "fake single" entity from multi entities?

Posted: Sun Jan 22, 2023 10:12 am
by Pi-C
DemerNkardaz wrote: Sun Jan 22, 2023 8:35 am I want to add to my mod high-tier structure that can and transfer and store the electricity, call it "substation facility".
But, it is impossible to apply multiple types to one entity, directly we can have only or electricity-pole or accumulator.

I thought about pasting two entity both from one item, but I don't think just add it to "place_result" will be works, and this need coordinates and removeablity of two spawned entities simultaneously to prevent item-entity duplicating "cheat".

What you thinks about this?
The usual way is to use one item that will place a placeholder entity. Listen to the build events, and if your placeholder is built, create the real (but hidden) entities which do the actual work at the same location (with some offset, if necessary). You must keep track of which hidden entities belong to which combined entity, so when the visible entity is destroyed or mined, you can destroy the hidden entities as well.

If you want to take a look, I've used this technique for Bio Industries -- but I'm afraid the code is not exactly easy to read.

Re: Making "fake single" entity from multi entities?

Posted: Sun Jan 22, 2023 7:15 pm
by DemerNkardaz
Pi-C wrote: Sun Jan 22, 2023 10:12 am
DemerNkardaz wrote: Sun Jan 22, 2023 8:35 am I want to add to my mod high-tier structure that can and transfer and store the electricity, call it "substation facility".
But, it is impossible to apply multiple types to one entity, directly we can have only or electricity-pole or accumulator.

I thought about pasting two entity both from one item, but I don't think just add it to "place_result" will be works, and this need coordinates and removeablity of two spawned entities simultaneously to prevent item-entity duplicating "cheat".

What you thinks about this?
The usual way is to use one item that will place a placeholder entity. Listen to the build events, and if your placeholder is built, create the real (but hidden) entities which do the actual work at the same location (with some offset, if necessary). You must keep track of which hidden entities belong to which combined entity, so when the visible entity is destroyed or mined, you can destroy the hidden entities as well.

If you want to take a look, I've used this technique for Bio Industries -- but I'm afraid the code is not exactly easy to read.
Thank you for answer!
Now I will think about it.