|Level of Understanding||Intermediate|
DeclareVariable <varname|varname[array extents]> [type] [global|script|local|object|globalkeep] [default value]
The name must consist of alphanumeric characters and underscores, and may not start with a number. Variable names must be unique in all accessible scopes (see below).
The type is any currently available Data Type. These may be built into LavishScript, an application such as Inner Space or Fury, or an extension such as ISXGenHack. If the type is not given when creating the variable, the variable will default to the string type.
There are five possible scopes for variables -- global, script, local, object, and globalkeep. The global scope is accessible anywhere in LavishScript -- other scripts, from console commands, etc. The script scope is accessible only within the current script. The local scope is accessible only within the current function. The object scope declares a variable to be only usable within the object that declares it. The globalkeep scope is the same as the 'global' scope except that it will not be deleted when the script ends. If the scope is not given when creating the variable, the variable will default to global if not created within a script, or local if it is created within a script.
Valid variable values are dependent on the data type. For example, strings contain any text, and ints contain any whole numbers. If the value is not given when creating the variable, the variable will default to whatever the data type says is default -- generally what would be considered empty or equal to zero.
declarevariable astring string global Something
allocates a globally-accessible variable named astring that is type 'string' with a value of "Something"
declarevariable anarray int script
declarevariable avar bool local false