Synchronize two inserters filters and network connections

Place to get help with not working mods / modding interface.
Post Reply
User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Synchronize two inserters filters and network connections

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

PyroFire
Filter Inserter
Filter Inserter
Posts: 356
Joined: Tue Mar 08, 2016 8:18 am
Contact:

Re: Synchronize two inserters filters and network connections

Post by PyroFire »

on_gui_closed and on_entity_settings_pasted

User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Re: Synchronize two inserters filters and network connections

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

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

Re: Synchronize two inserters filters and network connections

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

User avatar
Linver
Fast Inserter
Fast Inserter
Posts: 158
Joined: Wed Jan 09, 2019 2:28 pm
Contact:

Re: Synchronize two inserters filters and network connections

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

Post Reply

Return to “Modding help”