![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | WolframR |
i heard you can’t get function States from await like yield can. so is it even possible to do that anymore?
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | WolframR |
i heard you can’t get function States from await like yield can. so is it even possible to do that anymore?
![]() |
Reply From: | ido |
As expected the outer function will wait for the inner function complition and will continue it’s run afterwards.
Just tried it out, it is possible and it works.
about yield, from: https://github.com/godotengine/godot/pull/39093
yield is now await
The yield keyword is removed in favor of await. You can use await some_signal which works the same as yield did before.
You can also do await my_func() which is the same as yield(my_func(), “completed”) but it also works if the function isn’t a coroutine:
it’ll just run synchronously and get the returned value. Note that if my_func() returns a signal, then it will wait for that signal to be emitted.
Here’s an example for those seeking:
func _ready():
await a()
print("done")
func a():
await get_tree().create_timer(1).timeout
print("timeout")
handre | 2022-12-15 11:32