🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Scripting system that allows multiple threads / multiprocessing

Started by
0 comments, last by markr 20 years, 1 month ago
Hi everyone. I''m aware at how (relatively) easy it is to embed something like Spidermonkey / Javascript into a C or C++ application. I would very much like to have a script for a character in a game that goes something like this:

// pseudocode

Walk to forest;
get firewood;
walk to house;
drop item;
// etc

Of course when the "walk to house" or "pick up item" is executed, it will take the character some time to walk to the house. So ideally, I want to be able to store on the object, the fact that bob is walking to the house (having calculated the route etc), and store the execution stack of the script, and be able to carry out other tasks while he''s walking there (like moving other NPCs, drawing stuff, and responding to user input) I''m not interested in using a native thread for each actor - that would be far too cumbersome. I''m just interested in having the ability to "block" out in a script, and continue it once a given action is complete. Also what would be useful would be to completely jump out of the script (say bob had some other stimulus which caused him to give up taking the wood to the house), and start a new one -some exception handling or signalling mechanism perhaps - or just the ability to stop a script at a given blocking point and abandon its execution context. Any ideas? Mark
Advertisement
Look for microthreads or coroutines.

Python generators work nicely. Stackless provides further support.

“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” — Brian W. Kernighan

[edited by - Fruny on May 16, 2004 6:33:27 AM]

[edited by - Fruny on May 16, 2004 6:35:44 AM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement