identifier isnt declarted in current scope even when it is

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

I have a signal_handler node with the following code


extends Node

var caller
var action
var check_interact

signal exec_dialogue(dialogues_param, id)
signal exec_scene(callback_param, id)

# declare all signal acks in here


# Called when the node enters the scene tree for the first time.
func _ready():
	var coin1 = get_parent().get_node("entities/collectibles/coin_1")
	coin1.connect("send_cmd", self, _send_cmd)
	# get_parent().get_node("entities/collectibles/coin_1").connect("send_cmd", self, _send_cmd)
	# declare all signal connections in here
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if (Input.is_action_just_pressed("interact") and check_interact):
		if(action[0] == "d"):
			#emit_signal("exec_dialogue", action[1], id)
			pass
		else:
			#emit_signal("exec_scene", action[1], id)
			pass
	pass

func _send_cmd(cmd, id):
	caller = id
	action = cmd
	check_interact = true
	pass

func spin():
	pass

This throws the error:


error (16, 1): The identifier "_send_cmd" isn't declared in the current scope

I also get a warning at line 16 (the connect statement) for FUNCTION_USED_AS_PROPERTY)

What is going wrong here? more context - coin1 is actually a child scene, it’s hierarchy exists in another scene.

:bust_in_silhouette: Reply From: jgodfrey

That 3rd arg to connect() needs to be defined as a String. So, instead of this:

coin1.connect("send_cmd", self, _send_cmd)

… you want:

coin1.connect("send_cmd", self, "_send_cmd")