Advertisement Jump to content
Sign in to follow this  

ScriptObject variable

This topic is 3560 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

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

Share this post

Link to post
Share on other sites
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.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!