#How do I get the node that fired a signal?

15 messages · Page 1 of 1 (latest)

vestal sluice
#

I'm trying to use the same function for multiple UI buttons and when I press them I want the function to get the "Info" Panel which is a variable menu thingy stored in each of the buttons.

Issue is is that I have no idea how to reference the button that called the function without directly making reference to the specific individual buttons because that would be stinky, and also without making a new script to copy into each of the buttons because I also think that would be stinky and that I should try to avoid it (even though I'm bad at programming).

Any help would be appreciated! Thank you!

gentle musk
#

so

#

you're trying to get the signal that has been emitted?

vestal sluice
#

here uhh

#

i got these 2 buttons

#

both have an info menu thingy

#

both are connected here

#

basically i want them to both be able to access their own info box after calling being pressed

#

issue is is that the script in question is not inside of themselves

#

so i just want to be able to reference that node that called the function in the first place

#

if that makes any sense

#

should i even be trying to do this?

#

or am i stupid?

spice snow
#

usually for something like that you would just add that info to the signal. in this case give the button a script and a new signal, then you connect a function to the pressed-signal which then emits the new signal containing the data you need.
there are also options to bind extra arguments to a function when connecting it to a signal. so you could for example have a single function you connect to all buttons, but then also bind the button node itself as an argument to each call. this is however mainly useful when connecting signals via code, as the types of variables you can bind when connecting using the editor interface (tick advanced inside the dialogue) are pretty limited, and don't seem to include nodes.

vestal sluice