Jump to content
  • Advertisement
Sign in to follow this  
BornToCode

Using the same variables withing different scripts.

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

I was doing if it was possible to actually have a variable in script A and have script B access that same variable even though they are running in different modules. That way when one script makes changes to that variable, the other script can see the changes. I know i can get this done if i have them in the same module, but i was wondering if there is a way to do the same thing when The two script do not share the same module.

Share this post


Link to post
Share on other sites
Advertisement
That depends on where that variable is set.
If you've registered it in the application, then it can be accessed throughout every module (unless you set a restriction). Otherwise (if you declare the variable in a script), I've heard (somewhere in this subforum, I think witchlord said that) that it's not directly possible. You will have to write functions that change and return the variables (they can also return a handle, so you only need 1 function) and import them where you need them.

Share this post


Link to post
Share on other sites
Sis-Shadowman is correct.

A global variable declared in one module cannot be imported into another module. You'll have to write some functions to access the value of the variable, and then import those functions instead.

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!