Sign in to follow this  
mk1x86

Angelscript save context

Recommended Posts

mk1x86    445
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.

Share this post


Link to post
Share on other sites
WitchLord    4678
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.





Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this