Jump to content
  • Advertisement
Sign in to follow this  
Maega

Keep script running

This topic is 3496 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Final question for quite a while I hope. Is there a way to keep the objects created in a script persistent until the application closes? I can see that as soon as the script ends, the objects are destroyed. What I want to do is have Angelscript handle my GUI. As you've seen with my other posts, the script handles the creation of the objects. My intention is to have the GUI actions described in the same script. So as of now, the script runs, ends, and everything is cleaned up. Which is great if that is what you want, but I don't :). Any suggestions? Is it nothing more than changing the way the C++ object is registered?

Share this post


Link to post
Share on other sites
Advertisement
After a script context terminates only the local variables are cleared up. Any global variables declared in the module will still remain alive.

I assume you're using the CEngine that you've shown in previous posts. The one thing that I saw with it that I think you may want to change is that it is an object instanciated by the script. Thus if the script declares the CEngine variable as a local variable, then the engine will be destroyed as soon as the script ends. You could just declare the engine as global variable in the script, and it will not be destroyed until you discard the module.

Though I think you may actually want to register the CEngine as a global property from the application, rather than having the scripts declare the engine variable. Do you intend to allow multiple instances of the CEngine type, or is it supposed to have one instance only?

Share this post


Link to post
Share on other sites
Then I suggest you register the CEngine type so that it cannot be instanciated by the script. Register it as a reference type (asOBJ_REF) instead of a value type, and omit the factory behaviour. This will prevent the scripts from instanciating the type, and force it to use whatever instance the application provides.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!