Can't get signals to work with gdscript.

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

The error: Invalid type in function ‘connect’ in base ‘LineEdit (LineEdit_Name.gd)’. Cannot convert argument 2 from String to Object.

Here is my code:
self.connect("text_changed", "../../../NPCPanel", "_changeVariable", [get_name()])

NPCPanel: func _changeVariable(name): #print(text) print(name) pass

It sais it has problems with argument 2 but there is only one and even if I remove it:
self.connect(“text_changed”, “…/…/…/NPCPanel”, “_changeVariable”)
I still get the same error.

I have no idea what’s wrong it should work I even got help in the chat but I can’t find what the error is. Changed it >30 times Tried researching/searching it but to no avail.

Answer:
“…/…/…/NPCPanel” had to change that in get_node(“…/…/…/NPCPanel”)

Answer: “…/…/…/NPCPanel” had to change that in
get_node(“…/…/…/NPCPanel”)

Aren’t they kind of the same?

All this path stuff is so error prone. What if you change the node name? Suggest to either use FindNode (if node name is unique and still has the renaming problem) or assign the node to a variable and pass it into the function that’s doing the connect.

duke_meister | 2018-07-12 22:20

I would recommend against referencing the parent. I believe godot is designed to disallow global variables

hungrymonkey | 2018-07-19 16:06