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
gamemaker_version The version of Game Maker. This is an integer. For version 7 this is 701 can be anything between 701 and 709. 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 701.
os_type Returns an integer indicating the type of Operating System that the code is running on (for valid values see the os_xxx constants below)
os_win32 Constant for Win32 Operating Systems
os_win64 Constant for Win64 Operating Systems
os_macosx Constant for Mac OS/X Operating Systems
os_psp Constant for Sony PSP platform
gamemaker_pro Indicates whether the game is created with the Pro Edition
gamemaker_registered Same as gamemaker_pro

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.
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)