Connecting multiple instance to the same signal.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BigDC

Question… I have 2 separate scenes/scripts. The 1st scene/script lets call S1, and the second scene/script lets call S2. So far so good. S2 scene/script gets info from a json file and stored into a dictionary in the script. So lets call the dictionary in this S2 cene/script “Dict_Info”. The S2 scene/script is dynamically created, there could be anywhere from 1 instance up to whatever amount. Every instance of S2 can send a signal which contains the “Dict_Info” dictionary and each instance of S2 is connected to the same signal which is heard by the S1 scene/script. Ok so far. So lets say you click on one of these S2 generated scenes, a signal is sent to S1 and runs a function, lets call this functiion “_run_this_code()”. Now here comes the problem, ALL the dictionaries from all the instances of S2 are sent to S1 to the _run_this_code() function, how can I get ONLY the dictionary from ONLY the S2 I clicked on? Please help, please? Thank You!

:bust_in_silhouette: Reply From: Inces

I am not sure if this is a connection problem

You are saying that clicking one instance of S2 provokes every other S2 to emit their signal.
I can see two possible causes of that :

  1. Clicking mouse on S2 is not made private, every S2 scene share the same input event.
    If so, than You just have to specify which one is active at the time, for example by activating it on-mouse-entered, and only in this condition letting it to process input

  2. You use global dictionary variable and all instances of S2 share only a reference to it, so it only looks like every instance is sending their info, but in fact it is one dictionary being affected every time single S2 changes something in it local dictionary
    If so, than You should use global dictionary duplicate() in local S2 script