Is there any documentation about using connections?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alextro
:warning: Old Version Published before Godot 3 was released.

I came from Construct and guessing that connections kind of similar to event system in Construct.Any info regarding to this topic is much appreciated since Godot is my first scripting game engine.

@alextro ~ If any of those answers was the correct one, would you mind checking its “Selected” checkbox?

Bojidar Marinov | 2016-03-19 10:32

Ah okay… not familiar with QA system before.

alextro | 2016-03-22 14:02

:bust_in_silhouette: Reply From: Freeman

Hi alextro. I think you will find everything you need to start here.

Also, if you have a questions or a problem that needs to be resolved fast, drop by at #godotengine - for example from Kiwi IRC

Thank you Freeman for offering an assistance. Hopefully in next chance I must discussing in group chat.

alextro | 2016-02-23 03:53

:bust_in_silhouette: Reply From: neikeq

Yes, Godot’s event system is based on signals.

The Godot documentation has this brief introduction to them from GDScript: GDScript reference — Godot Engine (latest) documentation in English

Here is some extra information:

The connect method has another optional parameter to specify the connection flags (you can use multiple flags with the | operator):

emitter.connect("signal", node, "method", [], CONNECTION_DEFERRED | CONNECTION_ONESHOT)
  • Deferred connections (CONNECTION_DEFERRED) queue their signal emissions and the connected methods are not called until idle time.
  • Oneshot connections (CONNECTION_ONESHOT) automatically disconnect themselves after the first emition.

You can also connect signals in the editor by selecting a node and clicking the plug button in the Scene dock:


This will popup a dialog with the list of signals. Signals declared in scripts are also visible. You can select one and click Connect…, which will popup this dialog:


In this dialog you can select a target node and method (optionally marking Make Function to create the method). You can also bind extra parameters if the target method requires them, and mark connection flags.

This basic example increases the button text by 1 when you press it:

extends Node

var counter = 0
onready var button = get_node("MyButton")

func _ready():
    button.set_text( str( counter ) )
    button.connect("pressed", self, "_my_button_pressed")

func _my_button_pressed():
    counter += 1
    button.set_text( str( counter ) )

Hi neikeq.
So if I’m not mistaken, connections is signaling an action to target node when condition is met or it just only set the flag?

alextro | 2016-02-23 04:04

Signals are emitted when certain action happens. For example, the BaseButton class emits the signal pressed when the button is clicked. This will call all the methods that are connected to that signal.
I updated the answer with an example increasing a counter everytime a button is pressed.

neikeq | 2016-02-23 11:30

Ah I’m starting to understand.
Is it necessary to pass a variable as a string when set a text?

alextro | 2016-02-23 13:09

Yes, that’s why I use str(). Otherwise you would get an error like this:
Cannot convert argument 1 from int to String.

neikeq | 2016-02-23 14:28

:bust_in_silhouette: Reply From: rgrams

They’re also covered a bit in this video: The other videos in the series have some pretty useful stuff too.

I watched the node series and the videos help me understand the idea.

alextro | 2016-02-23 03:48

:bust_in_silhouette: Reply From: adrian_scheff

There’s an in-depth guide about Godot’s signals published on It starts by explaining the basics. Then it dives into the advanced features (passing parameters, bind array, flags, etc)