Making "fake single" entity from multi entities?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
DemerNkardaz
Inserter
Inserter
Posts: 26
Joined: Wed Jan 18, 2023 12:32 am
Contact:

Making "fake single" entity from multi entities?

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

Pi-C
Smart Inserter
Smart Inserter
Posts: 1644
Joined: Sun Oct 14, 2018 8:13 am
Contact:

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

Post 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.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
DemerNkardaz
Inserter
Inserter
Posts: 26
Joined: Wed Jan 18, 2023 12:32 am
Contact:

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

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

Post Reply

Return to “Modding help”