4 - Syntax

4.1 - Variables and flags
4.2 - System constants
4.3 - Values
4.4 - Actions
4.5 - Conditions

In this section the GTAC sublanguage will be studied in details. Full syntax will be provided in some theoretical manner in order to allow for a later reference.

4.1 - Variables and flags


Variables and flags can be used in GTAC in order to record events during the game.

A variable is of type integer and can assume any positive or negative value in the 32 bit range (i.e. -7fffffff - 7fffffff). Every variable is initialised to 0 at the beginning of every game and after every restart. The first 10 variables (i.e. var 0 - var 9) can be linked to a string, describing its use. These are displayed in the Status Window (see section 5). The number of gold pieces or remaining provisions can be stored in a variable, for example.

A flag can be either True or False. Every flag is initialised to False at the beginning of every game and after every restart. For example, a door can be locked (True) or unlocked (False). A key is being either carried (True) or not carried (False). Every flag can be linked to a description string, thus constituting an item. This string can be displayed in the Inventory Window if its flag is True. The status of a door (locked or unlocked) will not be displayed with other carried items, while a key or a sword will be. Every aspect concerning flags can be edited in the Items Window (see section 5).

4.2 - System constants


Listed below are the limits to the maximum number of system resources allowed.

Name Max val Description
max_room 999 locations - 1, i.e. 0 - 999
max_flag 999 flags - 1, i.e. 0 - 999
max_var 999 variables - 1, i.e. 0 - 999
max_pic 999 pictures - 1, i.e. 0 - 999
max_invent 20 items in Inventory Window
max_status 9 variables in Status Window - 1, i.e. 0 - 9)
max_sample 76 samples - 1, i.e. 0 - 76
max_name 10 enemy's name length
rand_max 7fffffffH random number

4.3 - Values


String Example
One or more characters in the range A to Z or a to z. No punctuation mark, spaces or other symbols are allowed. Goblin

Unsigned integer Example
One or more digit, without any sign preceding them. 0 123 4003

Integer Example
A sign '+', '-' or nothing, followed by an unsigned integer. +5 5 -5

Value Description
Integer see above
v<unsigned int i>
(i = 0 - max_var)
returns the value of variable <i>
r<unsigned int i>
(i = 1 - rand_max)
returns a random value between 0 and rand_max
E.g.: 6 -7 v3 r12

4.4 - Actions


Actions should be typed without leading spaces, in lower case.

The Test Luck and Fight commands, examined below, assume that you have declared three Status Variables as:

Var # Name

Your Skill score reflects your swordsmanship and general fighting expertise; the higher the better.

Your Stamina score reflects your general constitution, your will to survive, your determination and overall fitness; the higher the longer you will be able to survive.

Your Luck score indicates how naturally lucky a person you are. Luck and magic are facts of life in the fantasy kingdom you are about to describe/explore.

Action Syntax Description Example
GO TO room r<unsigned int i> go to room <i> (i = 0 - max_room) r5
RESET flag -<unsigned int i> set flag <i> to 0 (i = 0 - max_flag) -2
SET flag +<unsigned int i> set flag <i> to 1 (i = 0 - max_flag) +2
TOGGLE flag !<unsigned int i> toggle status of flag <i> (i = 0 - max_flag): 0 -> 1 and 1 -> 0 !2
SET variable v<unsigned int i>,<value v> set variable <i> to value <v> (i = 0 - max_var) v4,v2 v4,-2 v4,r5
ADD variable a<unsigned int i>,<value v> add variable <i> and value <v> and store result in variable <i> (with i = 0 - max_var) a4,v2 a4,-2 a4,r5
SUBTRACT variable s<unsigned int i>,<value v> subtract variable <i> and value <v> and store result in variable <i> (i = 0 - max_var) s4,v2 s4,-2 s4,r5
INITIALISE variable i<unsigned int i1>,<unsigned int i2> initialise variable <i1> to <i2> + random integer between 0 and <i2> (i1 = 0 - max_var, i2 = 0 - rand_max); i2,6
TEST luck t<unsigned int lucky_room>,<unsigned int unlucky_room> test your luck and continue from room <lucky_room> or <unlucky_room> t10,5
FIGHT enemy f<string name>,<unsigned int skill>,<unsigned int stamina>,<unsigned int win_room>,<unsigned int lose_room> fight against enemy called <name>, whose skill is <skill> and whose stamina is <stamina>.
BEEP b This is the standard RISC OS bell-like sound. b
PLAY SAMPLE p<unsigned int sample> This plays sample <sample> with sample = 0 - max_sample. Sample <sample> must have been loaded and fine tuned, otherwise no sound is generated (see section 5). p0

4.4.1 - Initialise

<i2> = 6 means roll one die and add 6, <i2> = 12 means roll two dice and add 12.

If <i1> lies in the 0 - max_status-1 range, the initialised value will be automatically stored into variable max_status+<i1> too, in order to allow for a later "restore to initial value". Thus, variables max_status - 2*max_status-1 are used as back-up for variables 0 - max_status-1. Variables in the 2*max_status - max_var-1 range are completely free to be used as you prefer.

This command is equivalent to v<i1>,r<i2>a<i1>,<i2>v<i1+max_status>,v<i1>

i4,6 will initialise variable 4 with a number between 7 and 12 and will copy this number in variable 14, as well, with max_status being 10.

i22,6 will perform just as i2,6 but will not copy any value in variable 32.

4.4.2 - Test luck

Test your luck and continue from room "lucky_room" or "unlucky_room", depending on whether you have been lucky or not. Two dice are rolled and their total score is compared against your luck, stored in variable 2. If your luck value is higher then or equal to this number, you have been lucky. At every luck test your luck value is decreased by 1 point.

4.4.3 - Fight enemy

Fight against enemy called "name", whose skill is "skill" and whose stamina is "stamina". If you win, go to room "win_room", else restart game. Your skill is assumed to be stored in variable 0 and your stamina in variable 1.

The enemy's skill score is turned in an attack strength, with a random number added to it. The same is done for your attack strength. If yours is higher than that of your enemy, you have wounded it. If its value is higher than yours, you have been wounded. The one who has been wounded gets its stamina score subtracted by 2 points. If both attack strengths are the same, you have avoided each other's blows.

At the end of every round you will be offered the chance to test your luck and to use it to reduce your damage by restoring 1 stamina point or inflict a severe wound to your enemy by subtracting extra 2 stamina points. If you are unlucky, however, your damage will be more serious, subtracting extra 1 stamina point, or your enemy's wound will be a mere graze, restoring 1 stamina point.

Another round with the same rules is played until yours or your enemy's stamina has been reduced to zero (death). If you die, the game restarts from room "lose_room". If "lose_room" is 0 the "You have been defeated by ..., your adventure ends here" message will be automatically displayed.

If you win, the game continues from room "win_room".

4.5 - Conditions


Conditions should be typed without leading spaces, in lower case. Conditions can be nested recursively.
Condition Syntax Description
True 1 Condition is always verified.
False 0 Condition is never verified. Although useless, it is kept for compatibility with other languages.
AND &(cond1,cond2) Condition is True if both subconditions cond1 and cond2 are True.
OR |(cond1,cond2) Condition is True if either cond1 or cond2 is True.
NOT !(cond) Condition is True if subcondition cond is False, and viceversa.
FLAG status ?<unsigned int i> Condition is True if flag <i> is True and False if flag <i> is False (i = 0 - max_flag)
IDENTITY =(<value v1>,<value v2>) Condition is True if value v1 = value v2, otherwise False.
GREATER THAN >(<value v1>,<value v2>) Condition is True if value v1 > v2, otherwise False.
SMALLER THAN <(<value v1>,<value v2>) Condition is True if value v1 < value v2, otherwise False.

4.5.1 - Examples

!(?0) Condition is True if flag 0 is False.

&(?1,!(?2)) Condition is True if flag 1 is True and flag 2 is False.

|(?2,!(&(?3,?4))) Condition is True if flag 2 is True or either flag 3 or 4 is False. In fact if both flag 3 and flag 4 are True, &( ... , ... ) will be True and !(...) will give False!


(C) 1994-2000 Andrea Gallo