Lionhead Challenge Language Documentation

Up to contents.

2 File Format

All valid Challenge Language files consist of four major sections, which must occur in the order specified in this section.

2.1 Comments

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!
*/

2.2 define script identifier arguments

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)

2.3 define value identifier = real

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:

2.4 Global Variable/Constant Declarations

These are values that can be accesed anywhere in your script.

  1. global variable
  2. global constant identifier = constant

2.5 Scripts

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:

  1. run script identifier
  2. begin script identifier
  3. arguments
  4. Local Variable/Constant Declarations and Initialisations
    1. identifier = expression
    2. constant identifier = constant
    3. identifier [integer]
  5. Script Body
  6. Script Exceptions
  7. end script identifier

2.4.1 global variable

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]

2.4.2 global constant identifier = constant

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:

2.5.1 run script identifier

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

2.5.2 begin script identifier

All scripts are begun by specifying their name in this way. After the name, you may give one or more arguments.

begin script LostBrother

2.5.3 arguments

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)

2.5.4 Local Variable/Constant Declarations and Initialisations

You may optionally specify local variables and constants within scripts. These must all be declared before the start keyword

2.5.4.1 identifier = expression

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}

2.5.4.2 constant identifier = constant

You may also define local constants, which are useful if you'd like to abbreviate long-winded enumerations.

constant ANIMAL = SCRIPT_OBJECT_TYPE_ANIMAL

2.5.4.3 identifier [integer]

You may also define local arrays.

MyArrayName[10]
MyArrayName[ArraySize]

2.5.5 Script Body

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

2.5.6 Script Exceptions

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.

2.5.7 end script identifier

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