Global Variables

Overview
Global variables are, as their name suggests, variables. If you do not know what this means, you can think of them as containers. If you have a global variable as a number type, like Short, this container can hold numbers. More complex objects, like vehicles, wont directly be held, but instead a reference to where Halo has them, will be stored.

Global variables can hold any Data Type. Depending on their type, you can inspect, or directly alter their values using Devmode. These operations can be done with commands such as Set, Inspect, or Print.

Halo has some global variables built in. All Cheat commands are actually global variables, like cheat_deathless_player

Example 1 - Using a number variable
(global short number 0) ;;Global named Number; Initial value is 0. (script continuous BSP stuffz (sleep 30000) ;;wait one thousand seconds (set number (+ number 1)) ;; increment the global variable, number. (switch_bsp number) ;;Set the BSP to the amount stored in number. )

Example 2 - Using a Boolean to run debug code
(global boolean debugging false) (script continuous something (sleep_until (volume_test_objects base_01_volume (players)) 5) ;;Wait until players enter volume. (device_set_position base_01_defenses 1) ;;Activate device fully (Move to open position) (if debugging (sv_say "debug: defenses on")) ;;If debugging variable is true, announce debug info. (sleep_until (not (volume_test_objects base_01_volume (players))) 5) ;;Wait until players exit. (device_set_position base_01_defenses 0) ;;Deactivate device (move to closed positon) (if debugging (sv_say "debug: defenses off")) ;;If debugging variable is true, announce debug info. )