Original Post
Hello. I come here with something i think it's an interesting question (hope it actually is ^_^) I was trying to make some script which are actually "entities" or "processes"; i like to call them Objects. Whatever the name, those scripts are intended to control one particular Sprite in the screen. For example a "projectile" Object would contain all the code to move a shot across the screen, a "character" Object would control a the player's character in the screen, a "monster" object would do the same for enemies... and so on... I've already created some C++ clases and functions which take care of animations, sprite loading, sounds, input handling, etc. and they are passed to the AngelScript Engine. There is a sort of "Yield" function, based on the examples of AngelScript's SDK, so that every Object can tell the main .exe when it has finished doing it's job for this frame. Now, the main intention of all this, is that scripts can create other Objects. For example, a Character Object would create a Projectile Object every time the player shoots. There could also be a Monster Spawner Object which takes care of creating some random enemies. Hope you are getting the idea. I was hoping that users of all this messy program could make their own Object, which means, they could declare some global variables to hold Sprite, Sound, Animation and other data, hoping that every Object that is created will have it's own copy of those variables, functions and, in general, it's own independent code. With this, we can create one type of Object and make it appaer tons of times on screen. The best example is the Enemy Object: We can place tons of enemies around the stage, by just changing their position and current animation; those could be recieved as parameters in the main function; those parameters change the global variables; later, every single enemy could have it's own current state, position, animation, etc. by just changing the Global Variables declared in the script for that Object, something the script itself can do. Now, my problem is the following: This cannot be achieved with contexts, since they share variables for the current module (Suposing every module contains the code for one Object). It can be done by using one module for every Object create, but this would mean that i'd have to recompile the code for that module every time a new object is created, which I suppose is not fast enought to do it on real time. I propose a "ClonModule" method for the Script Engine class, which creates a copy of one module, to a new module with just a different name; hoping, of course, that it would be fast enought to do it real time. Hope i was clear enought.