Q: What should I know about global variables?

A: Global variables are variables declared at script scope; you cannot declare file-scope variables. For instance, int the following snippet, x is a global variable:
Code:
ffc script foo {
   int a;
   void run() {
      int b;
   }
}
Some notes on global variables:

-Global variables are implicitly stored in the GD registers and are thus persistent: they are saved with the quest.

-A global variable is visible "as-is" to all methods and other global variable declarations within the same enclosing script; global variables are accessible from other scripts, or from global functions, using the dot operator: in the above example, a can be accessed using "foo.a" by other scripts.

-Only simple types (int, float, bool) are allowed to be stored in global variables. Pointer types become stale after every frame, and so cannot be safely used globally.

-Global variables are initialized once, when a player first begins a new quest. Within a script, they are guaranteed to be initialized in declaration order. It is unspecified which of two scripts' global variables are initialized first.