Author Topic: Global and local variables  (Read 1325 times)

What's the difference between Global and local variables?

wich is wich also?

one is % I think that's local.
The other is $ and I think it's global, not sure though.

Global is global throughout all your scripts. You could use a global variable in one script and access it in another.

Local is only to that script.

Also, you got them right.

You pretty much got global right, but local variables can only be used within their FUNCTION. Not the whole script.

local variables are also the ones you would assign to objects-- including players.

You can assign local variables to anything.  %var could be 1 or it could be "ice cream".  It doesn't matter.

You can assign global variables to anything.  $var could be 1 or it could be "ice cream".  It doesn't matter.

Local is only to that script.

Not quite. Local variables can only be used within the function that they're in, they cant be accessed from outside of that function.

Local is only to that script.

Not quite. Local variables can only be used within the function that they're in, they cant be accessed from outside of that function.

I guess Ephi missed this:

You pretty much got global right, but local variables can only be used within their FUNCTION. Not the whole script.