Keywords

answers
Denotes that following will be a set of possible responses to a previous call to the ask method. The code block following the answers keyword should consist only of keywords, each with their own code block for their own handling code.

code
Denotes a code block will be following. This keyword is mainly intended to handle several original game scripts that have intermixed their databases in the middle of the code, and it is recommended that you not use this keyword in new scripts.

const
Specifies a following identifier be assigned to represent a constant value. The following example illustrates the format for specifying constants:

     const integer FEMALE_SEX = 3;
Currently, only constant integers are allowed, so the integer keyword is optional and may be ommitted. The value to the right of the equal sign must be a number, or an expression that evaluates to a constant value - it cannot, for example, have fields or other non-constant variables in it.

converse and converse2
The converse code block denotes the block of code that handles the conversation with the NPC or object to which the script is associated. It should follow in the script after the identify and look keywords. The only difference between using converse and converse2 is that the converse2 keyword inserts an extra prefix byte before the start of the conversation script. It is currently unknown exactly what this extra byte does, but several scripts include it.

db
Signifies the start of a datbase. It should be followed by a name and then a braced set of either integers or strings - the two cannot be contained in the same database. Note also that a database definition must be outside of any code block.

do
The do keyword can be used to construct a do/while loop - the following format is used:

     do { code block } while (test-condition);

else
The else keyword can be used after a statement or code block that follows an if statement to specify a following code block or statement that should be executed if the if statement's condition evaluates to false

elseif
The elseif keyword can be used in place of an else keyword to specify a new if statement that should be evaluated if the previous if statement evaluated to false. This keyword is just a shorthand - an equivalent function could be obtained by having an else code block whose first statement is an if statement.

global
The global keyword can be used as a prefix to a string or integer variable definition to specify the variable is to be a global, as opposed to a variable that is local to the script. An example is the following statement:

     global integer V_SEX:16;
This statement defines a symbol 'V_SEX' that will represent global variable number 16, which happens to be set by the engine to be 0 if the player is male, and 1 for female. This particular variable is one of many already hard-coded by the compiler.

identity
The identity keyword should be the first keyword within a script. It should be followed by a braced block that contains both a name and num statements. The identity block identifies both the NPC name and script number to uniquely identify what NPC the script belongs to.

if
The if statement specifies a conditional test that causes the following statement or code block to be executed only if the result of the test is true. An if statement can also optionally have either an else block that specifies a code block or statement that is executed if the test is not true, or an elseif statement, which is a shortcut for an else block that immediately contains another if statement.

integer
The integer keyword is used to specify an integer variable, either an integer field or a constant. The following two lines give the possible formats of the integer keyword:

	const [integer] MAX_NUM = 10;
	integer Index[:Field Index] [= initial value];
When defining constants, the use of the keyword is optional, since currently only integers can be defined as constant. For defining fields, you can optionally specify both a specific index and/or an initial value. If a field index is not specified, than the next free local field that isn't already being used by a variable is taken. The engine alloactes the field ten field indexes, 0 to 9, as local variables, whilst the rest are defined as global variables. Several of the global variables have special meaning to the interpreter, and have default variables to represent. See the Symbol Table List for more information.

jump
Causes execution to jump to the specified destination. Destination labels can be specified in the source by specifying the name followed by a colon.

keywords
Valid only within an answers block, the keywords keyword specifies a set of possible responses to the last ask or askc method call - if the response matches one of the comma separated values in the string, then the following code block is executed. The special string of * matches any response, and is always the last keywords entry of an answers block.

The interpreter will always match an answer based on the length of the comma separated values of each keywords entry. Thus, a value of "brit" will match if the user typed in "british", "britannia", or anything else that begins with "brit". To save space, most of the standard scripts only use four character long strings, but this is entirely up to the programmer of how long the comparison strings should be.

look and look2
The look keyword specifies what is display when the NPC the script is associated with is looked at. The keyword can be either followed by a double quoted string, or by a code block. If a code block is provided, any textual display should be done via Printable Strings. The only difference between using look and look2 is that the look2 keyword inserts an extra prefix byte before the start of the look script. It is currently unknown exactly what this extra byte does, but several scripts include it.

name
This keyword is used within the Identity block to specify the NPC's name

num
This keyword is used within the Identity block to specify the script number that uniquely identifies this script, and also identifies which NPC the script belongs to.

string
The string keyword is used to specify a string variable. For more information on the format for defining variables, see the Integer keyword.

while
The while keyword can be used in either a do/while loop or as a while loop block. The difference between the two is that the first form executes the specified statement or code block before performing the test the first time; the other does the test first and doesn't execute any of the code if the test isn't true. The format of these constructs is shown below:

	do { code block; } while (test-condition);
	while (test-condition) { code block; }