Wait for animation in every function in the call stack

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gd_question

Lets say I have a function func_20 that calls func_19, that in turn calls func_18 and so on until func_1. The call stack is func_20 → func_19 → func_18 → … → func_1. And they all use prop1:

func func_n():
    .........................
    .........................
    func_n-1()
    use_prop1()
    .........................
    .........................

Then at some point I change func_1 so it starts animation that changes prop1 and wait until the animation ends before it continues with whatever it is doing:

func func_1():
    .........................
    .........................
    start_animation()
    wait_for_animation_end()
    use_prop1()
    .........................
    .........................

How do I wait for this animation without making changes in other methods in the call stack?

:bust_in_silhouette: Reply From: SnapCracklins

Could you perhaps tie your function trigger to the animation_finished signal? Then have a simple integer variable that goes up every time. This code is pretty rough but maybe it will get you close?

var _funcstate = 1
func on_animation_finished(_anim_name):
        ### INSERT FUNCTION HERE
        _funcstate = _funcstate+1
        _func(funcstate)

I don’t understand your proposal, can you elaborate? Which function should I insert - fun_1, func_2, func_15? What is _func? What function trigger? And how does a simple counter help me to keep the rest of the functions - func_2, func_3, …, func_20 unchanged?

gd_question | 2022-08-09 00:29