So say I have the script ('button' is a button control in my scene)
func _ready():
var test_value = test()
print('you should only see this after test() fully finished')
#this means test_value should now be 'DONE'
print(test_value)
#however 'DONE' is never printed! Instead, I get '[GDFunctionState:546]'
func test():
print('started test')
yield(button, 'pressed')
print('finished test')
return 'DONE'
How do I stop this kind of asynchronous behaviour? Reminds me of JS promises except it isn't.
I also tried doing while test_value extends GDFunctionState: continue
to try and stall execution until I get my test_value
...however, doing this just hangs my game, I only see the Godot logo and it keeps loading forever :(.
Any help is greatly appreciated, I've wasted tons of time on this & still can't solve it.