YoYo Games Wiki

Global variable

From YoYoGames Wiki

A global variable is a variable who's scope is global. There are many built-in global variables which are related to game settings and users may also define their own global variables using the scope resolution operator.

Defining global variables

To define a variable as global it must be placed in the global scope using the global keyword and the scope resolution operator:

{
 global.happy = 6;
}

or be defined using the globalvar keyword:

{
 globalvar happy, sad;
}

If a global variable is defined with globalvar the variable's symbol is assumed to be global when used in the current scope. This means that it no longer needs to be prefixed with "global." when referenced in the current scope.

See Also