GML Functions: Miscellaneous Variables and Functions

Here are some variables and functions that deal with errors.


 * error_occurred Indicates whether an error has occurred
 * error_last String indicating the last error message
 * show_debug_message(str) Shows the string in debug mode
 * debug_mode This read-only variable indicates whether the game is running in debug mode.

The following variables can be used to make sure your code will work for the appropriate version and edition of Game Maker.


 * gamemaker_pro Indicates whether the game is created with the Pro Edition.
 * gamemaker_registered Same as gamemaker_pro
 * gamemaker_version The version of Game Maker. This is an integer. For version 8.0 this can be anything between 800 and 809. For version 8.1 this will be something between 810 and 819, etc. So never check a particular version but better check for a range. This variable is not available in version before 800.

The following functions exist that allow you to check whether certain variables exist and with which you can set variables and get their values. In all these functions the variable name is passed as a string!


 * variable_global_exists(name) Returns whether a global variable with the given name (a string) exists.
 * variable_local_exists(name) Returns whether a local variable with the given name (a string) exists for the current instance.
 * variable_global_get(name) Returns the value of the global variable with the given name (a string).
 * variable_global_array_get(name,ind) Returns the value of index ind of the global array variable with the given name (a string).
 * variable_global_array2_get(name,ind1,ind2) Returns the value of index ind1,ind2 of the global 2-dimensional array variable with the given name (a string).
 * variable_local_get(name) Returns the value of the local variable with the given name (a string).
 * variable_local_array_get(name,ind) Returns the value of index ind of the local array variable with the given name (a string).
 * variable_local_array2_get(name,ind1,ind2) Returns the value of index ind1,ind2 of the local 2-dimensional array variable with the given name (a string).
 * variable_global_set(name,value) Sets the global variable with the given name (a string) to the given value.
 * variable_global_array_set(name,ind,value) Sets the index ind in the global array variable with the given name (a string) to the given value.
 * variable_global_array2_set(name,ind1,ind2,value) Sets the index ind1,ind2 in the global 2-dimensional array variable with the given name (a string) to the given value.
 * variable_local_set(name,value) Sets the local variable with the given name (a string) to the given value.
 * variable_local_array_set(name,ind,value) Sets the index ind in the local array variable with the given name (a string) to the given value.
 * variable_local_array2_set(name,ind1,ind2,value) Sets the index ind1,ind2 in the local 2-dimensional array variable with the given name (a string) to the given value.

For example, you can write:

{  if variable_global_exists('ammunition') global.ammunition += 1 else global.ammunition = 0 }

You can also use these functions to pass variables to a script in a sort of by-reference way, by passing their names as strings and using the functions to change them.

You can change the program priority using the following function:


 * set_program_priority(priority) Sets the priority for the program. You can indicate a value between -3 and +3. A value of -3 means that the program will only run if no other process on the computer requires processing time, or stated differently, when all other processes are idle. Values of -2 and -1 are below normal, so other processes will get priority. 0 is the normal value. +1 and +2 give a higher priority, resulting possibly in higher speed and smoother game flow. But other processes will get much less processing time. +3 indicates real-time mode. In real-time mode basically all time is allotted to the game. This can lead to serious problems with any other applications running on the computer. Also keyboard events and e.g. the pressing of the close box might no longer be recorded by Windows. So only use this if you want all the processor time. Also better check carefully before using it and save the game before running.

Finally, you can use the following function to set the title of the application:


 * set_application_title(title) Sets the title of the application to the given string. The title is for example shown in the task bar.