Global
The global command defines a public variable which is available anywhere in the program at any time. All references to a global refer to the same variable and must have a unique name, different from any other global variable, attribute, property, or object. It is a declaration and is not executable code.
! Global variable to store the number of chocolate cake slices.
global cake_slice_count
global table, chair
global car = Ford ! car variable is Ford object
global batteries = 5 ! number started with
global current_color = "Viridian"
! Global variable to store the number of chocolate cake slices,
! with a starting value defined right at the start.
global cake_slice_count = 10
Some reserved global variables are defined by the compiler:
Variable name | Used for |
---|---|
object | Direct object of a verb action |
xobject | Indirect object |
self | Self-referential object |
words | Total number of words in word array |
player | The player object |
actor | Player, or a char. (for scripts) |
location | Location of the player object |
verbroutine | Current verb routine |
endflag | If non-false, run EndGame |
prompt | The character(s) used for the prompt (to let the player know when it’s time to type their next command next command to the game.) |
objects | Total number of objects |
system_status | After certain operations |
The Hugo Library also defines several global variables, including:
Variable name | Used for |
---|---|
STATUSTYPE | The type of information used in the status bar 0 - no status 1 - score/turns 2 - time of day |
TEXTCOLOR | The default color of the text that is printed for interpreters that support it |
player_person | 1=first, 2=second, 3=third |
MAX_SCORE | Total possible score in game |
FORMAT | Contains bitmap of format masks |
DEFAULT_FONT | 0=monospaced normal text |
UNDO_OFF | Overrides undo when true |
counter | Elapsed turns (or time, as desired) |
score | Accumulated score |
verbosity | For room descriptions 0 - BRIEF 1 - SUPERBRIEF 2 - VERBOSE |
speaking | Set to whatever character the player is currently speaking to |
old_location | The previous location |
obstacle | if set to an object, that object prevents the player from leaving the room |
light_source | Current object providing light (can be the location); set by FindLight |
event_flag | event_flag value determines whether actions like waiting should be interrupted |
need_newline | true when newline should be printed |
See Also: local