- Edited
In 3.X functions containing a yield would return a GDScriptFunctionState
instead of crashing.
But in 4.X, if I were not sure if my function I want to get an output value from is async or not, and I also don't want to wait for the function if it is async, what can I do?
E.g.
func maybe_async_function():
#I know this function doesn't return a value because it awaits on something
# and i don't want _ready() to await for this
await get_tree().create_timer(2).timeout
func maybe_async_function2():
return true
func _ready():
#i don't know if i'm calling an async function or not
var caller = Callable(self,["maybe_async_function","maybe_async_function2"].pick_random())
#call without await:
var val = caller.call()
I could solve this by adding another function which makes the await call but that adds more clutter.