Skip to content

Commit b12476f

Browse files
authored
Merge pull request #10625 from Vocco/update-bound-signal-args
Update binding Signal connection args docs
2 parents 05ac0be + 4421c62 commit b12476f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

tutorials/scripting/gdscript/gdscript_basics.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,20 +2449,19 @@ arguments when you emit signals; it's up to you to emit the correct values.
24492449

24502450
.. image:: img/gdscript_basics_signals_node_tab_1.png
24512451

2452-
GDScript can bind an array of values to connections between a signal
2453-
and a method. When the signal is emitted, the callback method receives
2454-
the bound values. These bound arguments are unique to each connection,
2455-
and the values will stay the same.
2452+
You can also create copies of GDScript Callable objects which accept additional
2453+
arguments using :ref:`Callable.bind() <class_Callable_method_bind>`. This
2454+
allows you to add extra information to the connection if the emitted signal
2455+
itself doesn't give you access to all the data that you need.
24562456

2457-
You can use this array of values to add extra constant information to the
2458-
connection if the emitted signal itself doesn't give you access to all the data
2459-
that you need.
2457+
When the signal is emitted, the callback method receives the bound values, in
2458+
addition to those provided by the signal.
24602459

24612460
Building on the example above, let's say we want to display a log of the damage
24622461
taken by each character on the screen, like ``Player1 took 22 damage.``. The
24632462
``health_changed`` signal doesn't give us the name of the character that took
24642463
damage. So when we connect the signal to the in-game console, we can add the
2465-
character's name in the binds array argument::
2464+
character's name using the bind method::
24662465

24672466
# game.gd
24682467

@@ -2472,7 +2471,7 @@ character's name in the binds array argument::
24722471

24732472
character_node.health_changed.connect(battle_log_node._on_Character_health_changed.bind(character_node.name))
24742473

2475-
Our ``BattleLog`` node receives each element in the binds array as an extra argument::
2474+
Our ``BattleLog`` node receives each bound element as an extra argument::
24762475

24772476
# battle_log.gd
24782477

0 commit comments

Comments
 (0)