Jump to content
  • Advertisement
Sign in to follow this  
dxj19831029

ScriptObject variable

This topic is 3406 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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!