Advertisement

Keep script running

Started by January 22, 2009 08:20 AM
2 comments, last by WitchLord 15 years, 10 months ago
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?
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?

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

Advertisement
Just one
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.

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