Jump to content

What's the point of global variables?


Recommended Posts

I can't compare a Global to a global, I can't compare a Global to an "int", I can't make "int" = Global. What is the point of it? Literally using it as a reliable way to track a script progress throughout multiple stages and it's useless.

  • Sad 1
Link to comment
Share on other sites

The point of a global variable is so that ANY script can access and/or alter the variable. If only 1 script is doing so then it doesn't need to be a global variable. Why are you trying to track stages with a global anyway when all registered quest stages act like a global variable in that ANY script can access and/or alter them.  Just like globals the game engine keeps track of them by default.

Link to comment
Share on other sites

12 hours ago, worm82075 said:

The point of a global variable is so that ANY script can access and/or alter the variable. If only 1 script is doing so then it doesn't need to be a global variable. Why are you trying to track stages with a global anyway when all registered quest stages act like a global variable in that ANY script can access and/or alter them.  Just like globals the game engine keeps track of them by default.

It's multiple variables that need to be tracked, not just 1. But I figured out a compromise without variables, just felt it was ridiculous that I couldn't use it the way I needed it to as my compromise might not even work all the way

Link to comment
Share on other sites

15 hours ago, Bount227 said:

just felt it was ridiculous that I couldn't use it the way I needed it

Just ignore your feel. You have a fact of global variables existence in their form. Nobody will change it. Accept it, and use or don't use them.

15 hours ago, Bount227 said:

It's multiple variables that need to be tracked, not just 1.

Perhaps, F4DS might help you.

Link to comment
Share on other sites

> I can't compare a Global to a global

Yes you can: if(myGlobalVariableA.GetValue() == myGlobalVariableB.GetValue())

> I can't compare a Global to an "int"

Yes you can: if(myGlobalVariableA.GetValue() as Int == IntVariable) OR if(myGlobalVariableA.GetValue() == (IntVariable as Float)) 

Although if your Global actually does contain a decimal you may want to use the Math.Ceiling() or Math.Floor() Int conversions.

> I can't make "int" = Global.

Yes you can: myGlobalVariableA.SetValue(IntVariable as Float)

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...