Advertisement

Angelscript save context

Started by March 16, 2010 10:14 AM
0 comments, last by WitchLord 14 years, 8 months ago
Hello, I'm new to Angelscript. Here is my problem: I want to use angelscript to control characters in my game. The script is able to call c++ methods like "walkTo(int x,int y)" and "say(string str)". in script: void foo(Character@ alice) { alice.walkTo(10,10); alice.say("Look, there! A cave"); alice.walkTo(16,34); // cave position } now walkTo just sets an internal state and calculates the path to the destination. The actual walking cycle is done per frame. My idea is to suspend the context when calling walkTo and when the walking is done it is continued. Say alice is walking to 10,10. While she's walking the user wants to save and leave the game. My problem is that the context is not done with the script. I must somehow save the state the context is in and just don't know how I could do that. Checked the manual but couldn't find anything related to this topic. Also the search function didn't really help me.
It's currently not possible to serialize the context state, though it is a feature I would very much like to add to the library. It will probably be a while before I can get to it though.

I suggest you instead write your scripts to be event based, i.e. whenever the actor needs to act on an event a script function is called to perform something and then immediately returns. The state would be stored in an object, rather than in the context. That way you will not have to worry about long running scripts that needs to be saved in the middle of the progress.





AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement