Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Diet Estus |
Suppose I have a function whose structure uses yield()
in the following way:
func my_func():
tween.start()
yield(tween, "tween_completed")
some_other_func()
Suppose that I call this function and before the tweening completes I decide that I no longer want the remainder of the function to be called.
Is there a way to manually break out of the function when it’s yielding?
I don’t know about when the function is yielding, but is there a way to check when the tween stops, and if it completes as normal, you could still yield it?
Ertain | 2018-11-11 16:59
Yeah, I could definitely build a workaround by adding some safety conditions into the function itself, for example:
func my_func():
tween.start()
yield(tween, "tween_completed")
if some_bool:
some_other_func()
else:
pass
But I’d prefer if there was simply an easy way to break out of the function externally, otherwise I’ll have to muddy up things with all kinds of single-use bools.
Diet Estus | 2018-11-11 19:07
If you stop the tween
before it gives off “tween_completed”, the yield
function will still go through? Can’t really think of another way around this. I did find this answer, but that involves using a signal, and I don’t entirely know how that will fit into this problem.
Ertain | 2018-11-12 02:03