The subject script:
extends ColorRect
onready var subject = get_parent().get_node('Page1')
func _ready():
var error = subject.connect('set_timer', self, 'ad')
func ad():
print('signal connected')
You are setting the function ad
to run when the signal set_timer
is emitted (not when it is connected). I cannot find an standard set_timer
signal (for reference Timer
nodes have a timeout
signal, perhaps that is what you want?). I'd suppose it is a custom signal you created. If you are not emitting that signal, Godot will not call ad
for you.
To emit a custom signal, in the script attached to the subject (Page1
), call emit_signal("set_timer")
. See Godot documentation on emit_signal
.
The following code is taken from Godot documentation on Sigals:
extends Node2D
signal my_signal
func _ready():
emit_signal("my_signal")
If you try to emit a signal that does not exist, you will get an error in the console like this one:
emit_signal: Can't emit non-existing signal "set_time".
However, in your case, I believe the signal exist, otherwise, when connecting you would have got the following error:
connect: In Object of type 'ColorRect': Attempt to connect nonexistent signal 'set_time' to method 'ColorRect.ad'