godot-docs icon indicating copy to clipboard operation
godot-docs copied to clipboard

Signal documentation not updated for Godot 4 regarding passing additional variables with signal (binds array)

Open lostminds opened this issue 1 year ago • 0 comments

Your Godot version: 4.2.1

Issue description: When adding a signal connection you can chose to add additional parameters to the signal call, beyond those emitted by the original signal. in Godot 3 you could apparently do this by adding the additional variables in a "binds array" as an additional parameter in the connect() call. And this is what the current Godot 4 also describes.

Screenshot 2024-01-12 at 10 57 45

However, it seems that in Godot 4 this behavior has changed, and using the code above will give you an error as the second parameter of the connect call is now a set of connection flags as described here: https://docs.godotengine.org/en/4.2/classes/class_signal.html#class-signal-method-connect

Instead, the Godot 4 way of doing this is to use bind() to add the additional parameters you want to pass to the callable in the connect() call.

So the incorrect current example: character_node.health_changed.connect(battle_log_node._on_Character_health_changed, [character_node.name])

Should be character_node.health_changed.connect(battle_log_node._on_Character_health_changed.bind(character_node.name))

Along with some changes in the text to describe this new way of doing things.

URL to the documentation page: https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript_basics.html#signals

lostminds avatar Jan 12 '24 10:01 lostminds