Page 1 of 1

Synchronize two inserters filters and network connections

Posted: Sun Jan 05, 2020 7:56 am
by Linver
Hi to all!
I'm here to ask help about what is the best way (or what is the only one because I haven't yet a solution) about this problem:
We are in control script, we have two entities that have inserter prototype, with some filter slots.
I want that when a filter is setted(changed/removed) in one of two will be setted in the other one and vice versa, same for circuit network connections(connections/disconnections), I don't mind that the cable is connected, only that both are on the same network.

I initially looking in Factorio events, but seems that there isn't a event related to "filter setted" or "circuit network connected".
Any suggestion?
Thanks for all answers in advance.

Re: Synchronize two inserters filters and network connections

Posted: Sun Jan 05, 2020 9:20 am
by PyroFire
on_gui_closed and on_entity_settings_pasted

Re: Synchronize two inserters filters and network connections

Posted: Sun Jan 05, 2020 4:35 pm
by Linver
Hi PyroFire, nice to talk to u again!
Sorry but I didn't have understand ur comment completely.
OK, I suppose that from on_gui_closed I can in some way get the entity associated to the filter gui (right?), and on_entity_settings_pasted?
The documentation (as always) is very generic:
on_entity_settings_pasted
Called after entity copy-paste is done.

Contains
player_index :: uint
source :: LuaEntity: The source entity settings have been copied from.
destination :: LuaEntity: The destination entity settings have been copied to.
I should presume that "entity settings" refer to wiki Manipulating entities - Copy entity settings:
  • Recipes for automated crafting machines
  • Recipe requests
  • Filters for filterable devices
  • Circuit network entities and connections
  • Railway settings
And is only trigger when a player copy and paste setting with [Shift] + [Right mouse button] followed by Shift + [Left mouse button], this is right?
What up when an entity is connected via cable to a one circuit network? Trigger one of this two events?

Re: Synchronize two inserters filters and network connections

Posted: Sun Jan 05, 2020 5:09 pm
by DaveMcW
PyroFire told you how to detect player events. There is no way in to detect circuit network events.

I recommend you run a wire between the two inserters and give them identical settings. If that looks bad, try making an invisible wire.

Re: Synchronize two inserters filters and network connections

Posted: Mon Jan 06, 2020 8:23 am
by Linver
Hi DaveMcW,
maybe I have understand, but about on_gui_closed:
on_gui_closed
...
Note: It's not advised to open any other GUI during this event because if this is run as a request to open a different GUI the game will force close the new opened GUI without notice to ensure the original requested GUI is opened.
What is this warning telling me? That if a player open another gui is not grant that this event will be trigger? But is grant that the gui of inserter will be closed correctly?