I have several native functions which rely on user data stored in the Context before execution. If I initialize a global variable with one of these functions, I find the Context does not contain any user data. This makes sense, because the function is called when building, which is before I create a context.
Is there any way I can supply user data to the context that is used to call functions that initialize global variables? Alternatively, is there a way I can access the current module during the execution of a native function (similar to asGetActiveContext)?
I'm open to suggestion. My basic design is to have scripts which attach to "objects" in my application. These objects execute a particular function (entry point) in their scripts. The scripts, therefore, run in the "context" of my objects. Native functions called from the script engine need to be aware of that context. For instance, a "string GetName()" global function might return the name of the object owning the script. Currently, I accomplish this by setting user data in the Context immediately before executing, but I don't see a way to set my user data when building a module. I would prefer to avoid defining some sort of global variable in the module which points back to my application object, but I do see that as a possible solution.