This feels like a silly question, but I haven't been able to find a straight answer.
I know that I can create custom signals with arguments like:
signal mySignal(someArgument)
And I can then emit that signal with data in the argument:
emit_signal(someVariable)
But when I connect the signal at the other end, I've got:
$SomeNode.connect("mySignal", self, "functionToRun")
And I'm not sure exactly how to reference the argument I've added to the signal?
I saw another source that suggested:
$SomeNode.connect("mySignal", self, "functionToRun", [$SomeNode.someVariable])
But I'm not really clear on how I'm supposed to reference the argument in the functionToRun()
.
I assumed it was going to pass the argument to whatever argument is declared in the function.
For example:
func functionToRun(localArgument):
# And when I reference "localArgument" in the function, it uses the value passed from the signal.
pass
But it doesn't seem to be doing that.
Can anyone shed some light on how this works? Even a link to a working example would be amazing.