Advertisement

ScriptObject variable

Started by April 19, 2009 09:23 PM
0 comments, last by WitchLord 15 years, 10 months ago
Hi, My question is this: if I had a script global variable, is this global variable shared by different script executing context? Example:

// Script code here
int total = 0;
int incAndGetTotal() {
    return ++total;
}
I called executeString("inAndGetTotal()", "scriptName", &context) twice with different context, are the results 1 and 2? Is there any context local variable? I want to write the same script code, but in each context execution, the total variable will be local for each context. Cheers
Yes, the global variables are shared between all contexts. The context is really just an execution thread with its own call stack.

No, there are no built-in context local variables. Though you can implement a context local storage, i.e. by using the dictionary add-on, then give one dictionary to each context. You can also duplicate the script module for each context, though you'll have quite a bit of memory overhead with that.

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