Parallel callback

Is there any way I can call a Python function when a Parallel or a Lerp has finished?

I mean: I’m trying to do a turn-based game, you know the scheme of this kind of games:
1- Set actions for the turn
2- Play animations for the actions
3- Wait until all animations have finished
4- Resolve the effects of the actions
5- Repeat from point 1 until a player wins…

Is in the waiting part where I’m stuck.
Any advice :bulb: about how to do this will be wellcome.

Thanks.

my 2 (euro)cents:

afaik there is no such function. However, there should be a function asking if the lerp/parallel is still running. When you call this function every frame, you will get a reply as soon as the lerp/parallel isn’t active any more. An Idea to reduce cpu load might be the following:

Your lerp normally/may use a (fixed) set of seconds. If you don’t want the user to act interactive, you just may use

time.sleep(fixed_set_of_seconds)

(after importing “time”)
When you want the user to be interactive, you can use the panda-task-manager. You can use the doLater-method there. Either “stand-alone” like time.sleep() if your lerp/parallel is completely predicatable or in combination with the first idea (use the doLater-method with a reduced fixed_set_of_seconds and then start checking each frame if the lerp/parallel has finished or is still running.

Correct me please if I am wrong. I am not a teacher… but I hope I could give some hints where to search :wink:

Regards, Bigfoot29

One possible way is to make a sequence around your Parallel like
Psyeudo

p= Parallel(...)
s= Sequence( p, callback)

Then your Parallel will be proceded and after it you callback
Martin

Thank you all.

Just trying to avoid Tasks and Time functions, Bigfoot, but I will try your ideas if I can’t make Martin’s work.

Hey men, you are FAST! :open_mouth: :smiley:
Thanks again.

[Update]:
Yeah Martin… that worked GREAT…
For anyone doing the same the code is:


seq = Sequence(parallel, Func(callbackFunction) )
seq.start()