How do I connect a signal without using a script

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

I am trying to follow the Godot in 24 hours book. In hour 5 there is a connection of a timer node to a timeout signal that is not attached to any script. This works on the enclosed project and a screenshot of the section is here

No script timeout function

Any assistance would be much appreciated as I cannot find any references to how to achieve this in the docs, this forum or any googled search result. The book itself does not give explicit instructions but merely refers the reader to a previous chapter which, ironically, uses a gdscript for all of the given examples.

:bust_in_silhouette: Reply From: kidscancode

The official docs have you covered.

Thanks Chris

I understand that I can script the timer event… in order to move forward with the tutorial i did exactly that…

The issue that I was trying to solve however is shown clearly in the image that failed to attach to my post… I will link it here as well hopefully that will shed some light on what I find perplexing…

As you can see in the shot there is NO script attached to the root node and yet the timeout() signal clearly shows the queue_free() function being called…

I could not (and still cannot) duplicate THIS behaviour nor find any instructions on how this might be possible… in the docs, forums, Ariel’s and George’s book, your book or YouTube site or anywhere else on the mighty Google web (they do own it now right? [sarcasm]

I can only think that perhaps as the project was done at the pre-launch stage that maybe the timer had a different set of bound methods… regardless it is a mystery and I (unfortunately) hate mysteries… [a tad obsessive perhaps]

Anyway I will mark as answered as certainly using script is the correct method anyway and solving the mystery is not something that virtually anyone else probably cares about… cheers

3clipse | 2018-12-16 03:08

Ah, seeing the screenshot clears up a lot! :slight_smile:

When you use the connect dialog, the parameter at the bottom is the name of the function you want to call on the node. queue_free() is a function every node has, without need of a script, so you can just put it there.

The important part to remember here is what it actually means to attach a script to a node. A node has a certain amount of built-in functionality, based on its type and the nodes it inherits from. Attaching a script to a node extends its functionality (hence the extends keyword), allowing you to define more properties and methods to it.

Since signal connection works by linking the signal to a function on the target node that can be called. If the target function is an already existing one, then there’s no need for a script.

kidscancode | 2018-12-16 04:13

:bust_in_silhouette: Reply From: maxkratt

I’ve had this problem too. My mistake was placing the parentheses at the end, queue_free() instead of just queue_free.

:bust_in_silhouette: Reply From: Meow

i was following that tutorial too (Godot v3.2) and got stuck on hour 5

but that tutorial is for Godot v3.0 so not everything will be same

in Godot 3.0 you can attach signal to built in functions for example “queue_free”
Godot 3.0

but Godot 3.2 doesn’t allows you to do that
enter image description here