Operations on global variables.

Post » Wed Jun 20, 2012 5:28 pm

I want to use a conditional statement to check if a global variable is divisble by 5, like this:

if ( myVariable % 5 == 0 )   ;Do stuff.endif

Which would not compile; the compiler says that operator can't be used on a global variable.

Next, I tried:

if ( myVariable as int % 5 == 0 )   ;Do stuff.endif

Which gives the error that a global variable can't be cast to int...

So I tried:

if ( myVariable - ( Math.floor( myVariable / 5 ) * 5 ) == 0 )    ;Do stuffendif

Which gives a huge load of errors. Casting to other types in any case doesn't work either.

What should I do?

Edit: Oh, I'm an idiot, I should have called GetValue() on it... trying that now...
Edit2: Yes, it works now, forgot that global variables are actually objects. I'll leave the post for anyone else who made this mistake, I guess.
User avatar
Heather beauchamp
 
Posts: 3456
Joined: Mon Aug 13, 2007 6:05 pm

Post » Wed Jun 20, 2012 3:53 pm

For globalvariable you need to get the value with a function

globalvariable property gVar automyvariable = gVar.getValue()
User avatar
Nienna garcia
 
Posts: 3407
Joined: Wed Apr 25, 2007 3:23 am


Return to V - Skyrim