I have simple “event scripts” which are basically commands which are used for loading and animating 3d models, handling text, audio, camera animations. They are used for the game’s semi-interactive cutscenes.
Although the scripts aren’t Python, each command is mapped to a corresponding Python function.
A pseudocode example would be:
play music fade screen wait 3 seconds Mylabel: play animation1 play animation2 goto Mylabel
this is just an example really. The point is this commands must be parsed one after another, jump to a line for goto’s and sometimes not go to the next line of the script for some amount of time.
As i said in the end corresponding Python functions are called, so the above example could be written with Python (I’m thinking of allowing Python together with out toy scripting language).
Right until now I had the “interpreter/executor” as a task. As a task is ran only when a frame is rendered and it can usually only run 60 lines per second, it quickly proved itself as a bad idea.
I’m asking, how else can this be done? A simple while True: loop for the "interpreter/executor will freeze the rest of the game and all of it’s processes. So what can I do? Should I look into threading? How does threading go with Panda’s own processes?
Finally, lets say that I used Python in the event scripts, would I read each line of the file and do exec(line)? because if I would just run it as a python module I don’t see how I could use Wait() without freezing everything else, or jump from one line to another in the script. Wrapping the whole script in a Sequence also doesn’t seem like an option for the reasons given above.