All valid Challenge Language files consist of four major sections, which must occur in the order specified in this section.
The Challenge Language file may contain comments, which are useful notes to remind you what you were thinking of when you wrote that part of the challenge. Comments come in two flavours; single-line and multi-line. You can nest comments as much as you like!
// this is a single-line comment /* * And this is a /* nested */ * multi-line comment! */
In scripts you may wish to make calls to functions which have not been created yet, if so you need to declare them
define script Land7Control
define script MyReminder(var1, var2, var3)
Global defines (like defines in C++), are assigned a value immediately. Declaring global defines is useful if you'd like to use one point of edit for values in code, and for quick runtime use over a global variable. Global defines can not be assigned a game constant, only a number.
define SIZE_OF_HOUSE = 20.7 define MAX_PEOPLE_IN_HOUSE = 4
See also:
These are values that can be accesed anywhere in your script.
A script contains local variables and constants, and statements which cause something to happen in the game. They may also accept any number of arguments, allowing you to write one script which can do lots of different things depending on the arguments you pass it. The various parts of the script are described in this section.
See also:
A global variable is a variable which can be accessed and changed from any script in the entire file.
global Sister
global TimeTillEnd = 300
global MaxCostValue = BlueCost
global CircleStones[12]
Global constants, unlike global variables, are assigned a value immediately, and that value may not be changed. Declaring global constants is useful if you'd like to use shorter names for game enumerations. Global constants can not be assigned a number, only a game constant.
global constant HEALTH = SCRIPT_OBJECT_PROPERTY_TYPE_HEALTH
See also:
This can be called outside of the body of a script, in which case it is an 'auto-run' script. Auto-run declarations are used to specify any scripts which are to be run immediately upon start-up. You will probably want to run all of the challenges this way, as the challenge scripts may simply wait until a certain condition is satisfied before they begin proper.
run script LostBrother
All scripts are begun by specifying their name in this way. After the name, you may give one or more arguments.
begin script LostBrother
You may pass any number of arguments you like to a script. The script treats these arguments as local variables, and assigns these variables the values you specify when you run the script using the run script command. If you want to use arguments in a script, simply put a comma-separated list of variables inside brackets immediately following the name of the script.
begin script MyScript(Object,Speed)
You may optionally specify local variables and constants within scripts. These must all be declared before the start keyword
You may declare and initialise local variables immediately following the beginning of the script, before the start keyword. These variables are visible only within the script itself, so you can have variables of the same name in different scripts.
Cow = create ANIMAL_INFO_COW SCRIPT_OBJECT_TYPE_ANIMAL at {3463.24, 3458.05}
You may also define local constants, which are useful if you'd like to abbreviate long-winded enumerations.
constant ANIMAL = SCRIPT_OBJECT_TYPE_ANIMAL
You may also define local arrays.
MyArrayName[10]
MyArrayName[ArraySize]
The body section of the script begins with the start keyword, which declares that the local variable declarations are well and truly over. The script body is where all the processing occurs. There are heaps of statements which you can use, and we'll come to them soon.
start
Exceptions are the really funky cool part of the Script Language. If any of the exceptions
succeeds, the script stops what it's currently doing, processes the exception, and then either
continues from exactly where it was interrupted, or exits, depending on the type of exception.
Exceptions in the main script body haven't been used in a long time, and my not work.
All scripts must be ended by specifying the name of the script once more.
end script LostBrother
This documentation generated by LHDOC, © Lionhead Studios 2000