godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.97k stars 3.23k forks source link

Mention `var x = await signal` retrieves parameters passed to signal #8393

Open revanj opened 1 year ago

revanj commented 1 year ago

Your Godot version: 4.1.3 Issue description: I recently learned that by doing var x = await signal_name, where signal_name is a signal instead of a function, x will be assigned the parameters passed to the signal (x will be array when there are multiple parameters). This behavior is immensely helpful for my project and enables a lot of interesting code patterns.

Unfortunately, I cannot find this behavior documented anywhere. I believe this should be documented on the GDScript page, in the section dedicated to await. The page currently only mentions await assigning function return values, but not the parameters of signals. For a long time this made me believe that awaiting signals with assignment is not possible. URL to the documentation page: https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html#awaiting-for-signals-or-coroutines

Saint-XIV commented 3 months ago

crazy this isn't mentioned its so helpful for using signals as an event bus