PDA

View Full Version : Arranging Scenes in Correct Order


utepbereed
11-21-2008, 09:11 AM
I am a relative newbie to Python and Vizard despite being more familiar with other programming languages. I am sure this question has been asked over a thousand times, but here goes again!
I have taken over a project at my University that was abandoned by a previous employee. We are trying to simulate various events on our Campus and have several scenes that should take place in a specific order. I have modified the scripts left by the previous employee so that they work individually, but now I discover when combined, all scenes try start at once resulting in errors. The program is rather large and complex, so I have broken my code into object classes and various support modules that I won’t post here. Instead, I have written a pseudocode example of the problem I am having, namely that all functions run at once instead of in series as we intended (We are not using threads). Any help you can offer is greatly appreciated!

farshizzo
11-21-2008, 09:19 AM
I would highly recommend using the viztask module to control the flow of your program. Each stage would be implemented as a task and the main function would just yield each stage one after the other:def stage1():
while SomeCondition:

#Do something each frame here

#Wait for next frame
yield None

def stage2():
while SomeCondition:

#Do something each frame here

#Wait for next frame
yield None

def main():
#Execute stage 1 and wait for it to finish
yield stage1()
#Execute stage 2 and wait for it to finish
yield stage2()

viztask.schedule(main())

There are a lot of examples in the docs showing how to use the viztask module. You can also ask here on the forum if you have more specific questions about it.