Jump to content
  • Advertisement

When to prepare context?

Recommended Posts

Hi all, I'm a new user to AngelScript and have been trying to integrate it into my C++ component-based game engine for the past week or so.
I've finally settled on a design where my script manager will add all the scripts to the script builder, build the module and prepare the context all at the start of loading a scene.Once that is done, the script system will execute the context (but only while the game is playing, if it is paused it will suspend the context).

However, I've been getting an error code asCONTEXT_NOT_PREPARED.

So was I wrong to prepare the context too early? and is there a better design I could follow for a component-based engine?


Thanks for your time and apologies if its too vague or too simple.

Share this post

Link to post
Share on other sites

Are you calling Execute on the same instance of asIScriptContext that you called Prepare on? If Prepare was successful (check the return code) then Execute shouldn't return asCONTEXT_NOT_PREPARED (unless you're calling it on a different instance that hasn't been prepared).


I cannot comment on your design decision. The description is way to vague for that. There is nothing wrong from AngelScript's point of view to prepare the context in one step of the setup to be used at a later step during execution, but the prepare could just as well be done just before the call to Execute in the same execution step. Which is better depends more on your surrounding engine design than AngelScript itself, e.g. how you manage the contexts, how you treat compile time errors versus runtime errors, etc.



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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!