Page 1 of 1

Make LuaEntity.copy_settings raise events

Posted: Tue Feb 25, 2020 2:25 am
by jan1i3
I would like LuaEntity.copy_settings to raise events of some kind for compatability.

I can see on_entity_settings_pasted and on_pre_entity_settings_pasted being modified so that player_index is optional, and an optional arg is added to LuaEntity.copy_settings to provide the player who did the copy pasteing if available.

Or adding a script_raised_pasted event, with source and destination fields just like the others.
This event may get the same player related treatment as mentioned above, though considering the other script_raised events do not have a player_index, it would be weird for this one to have it.


I personally can live with using script.raise_event to raise them myself, however in this case i would appreciate a concise specification of which entities can copy paste to which entities.
I am aware of LuaEntityPrototype.additional_pastable_entities, however you can copy from crafting machines to requester chests for example, which is not included in this property, and i was not able to find a list or something similar which contains all these special cases.
(I can try to find all cases myself with testing and experiance, i'm just worried i would miss some)

I would like to add that i am still against using script.raise_event for anything, so i would appreciate if i (or anybody) would not have to.

Re: Make LuaEntity.copy_settings raise events

Posted: Tue Feb 25, 2020 4:53 pm
by Rseding91
What's the use-case specifically? There are several ways settings can be changed through the API that aren't triggering any events (and won't be) so why make this one in particular trigger events?

Re: Make LuaEntity.copy_settings raise events

Posted: Tue Feb 25, 2020 8:26 pm
by jan1i3
I didn't know there were multiple ways.

My specific usecase would be to have an area paste tool, which is basically just a selection tool, and all selected entities get settings pasted from the current player.copy_source_entity.
I wanted it be behave just like the player pasting on the machines, so that other mods which add additional paste functionality (such as rotation or modules) would also apply their action.

Re: Make LuaEntity.copy_settings raise events

Posted: Tue Feb 25, 2020 8:32 pm
by jan1i3
To be 100% accurate, i know you can paste using blueprints, but it felt like a very hacky way to copy settings when there is a literal copy_settings function, so i scrapped that idea.
However i am still open to using this approach.

Re: Make LuaEntity.copy_settings raise events

Posted: Tue Apr 21, 2020 11:39 pm
by jan1i3
With more experience now I'd like to retract this request.
I also now saw that i misread RSed's response, and i totally agree
(or rather have no reason).

I don't think i can close it myself, but i personally see it as closed.