Copy-paste entity settings for EEI

Place to get help with not working mods / modding interface.
Post Reply
PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Copy-paste entity settings for EEI

Post by PFQNiet »

I have some custom entities that use the electric-energy-interface as the "base". I'd like to be able to support copy-pasting of entity settings between them, but attempting to copy settings from an EEI doesn't seem to do anything.

Is there any way to enable copy-paste on entities that don't otherwise support it?

If not, I suppose I could always overlay a constant-combinator over the whole thing but then the tooltip will be for that instead of showing the power needs of the entity...

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Copy-paste entity settings for EEI

Post by DaveMcW »

electric-energy-interface does support copy/paste. Please describe exactly what you tried to do, and exactly what you want to happen.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Copy-paste entity settings for EEI

Post by PFQNiet »

The EEI has settings associated with it, and I want to be able to copy-paste them with shift-left/right clicking. But, as you mention, EEI doesn't support copy-paste. I wanted to know if there's a way to force it. I know entities can be forced to accept pastes, but allowing copy is another matter...

User avatar
NotRexButCaesar
Smart Inserter
Smart Inserter
Posts: 1122
Joined: Sun Feb 16, 2020 12:47 am
Contact:

Re: Copy-paste entity settings for EEI

Post by NotRexButCaesar »

PFQNiet wrote:
Tue Aug 03, 2021 6:25 pm
But, as you mention, EEI doesn't support copy-paste.
DaveMcW wrote:
Tue Aug 03, 2021 5:08 pm
electric-energy-interface does support copy/paste.
Emphasis added
DaveMcW wants you to be more specific about what you did.
—Crevez, chiens, si vous n'étes pas contents!

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Copy-paste entity settings for EEI

Post by PFQNiet »

Oh whoops, I misread.

I made an electric-energy-interface prototype with 20MW consumption, placed it in game and tried to copy settings from it with shift-right click. There was no sound and no green highlight box around it.

However I'm realising now... The UI type is none since it's a fixed consumer and not a player-controlled thing. Maybe that's why I can't copy from it?

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Copy-paste entity settings for EEI

Post by DaveMcW »

Apparently electric-energy-interface is hard-coded to only support copy-paste if it has a gui. You can get a gui in the map editor, but that does not help normal users.

Maybe you can replace the gui in on_gui_opened so it still exists but the player can't use it.

PFQNiet
Filter Inserter
Filter Inserter
Posts: 289
Joined: Sat Sep 05, 2020 7:48 pm
Contact:

Re: Copy-paste entity settings for EEI

Post by PFQNiet »

Since the setting is a toggle and the building in question cannot be rotated once placed, I went and implemented this as "hit the Rotate key to toggle the mode without having to open the GUI" instead. It's a convenience feature anyway and the control is now in the entity-description text so it's all good.

Thanks for the help, sorry for misreading XD

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Copy-paste entity settings for EEI

Post by eradicator »

For future readers: You can use the on_entity_settings_pasted event to implement custom behavior.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Copy-paste entity settings for EEI

Post by DaveMcW »

eradicator wrote:
Wed Aug 04, 2021 10:52 am
For future readers: You can use the on_entity_settings_pasted event to implement custom behavior.
on_entity_settings_pasted is inconsistent, which is why this thread exists. The event does not trigger for an electric-energy-interface with no gui.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Copy-paste entity settings for EEI

Post by eradicator »

DaveMcW wrote:
Wed Aug 04, 2021 2:04 pm
eradicator wrote:
Wed Aug 04, 2021 10:52 am
For future readers: You can use the on_entity_settings_pasted event to implement custom behavior.
on_entity_settings_pasted is inconsistent, which is why this thread exists. The event does not trigger for an electric-energy-interface with no gui.
Apologies. I thought the thread was about the EEI not supporting "natural" pasting. I don't see anyone mentioning events. In that case one could try to hack their own event using linked game controls 'copy-entity-settings' and 'paste-entity-settings'. And possibly LuaPlayer.entity_copy_source?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”