One of the most important things an adventure game author can do to help someone enjoy his game is to allow multiple wordings for commands. This minimises the chance that the player must play a mini-game of 'guess the verb' to find the name the author has given to a command.
For example, if 'exit' is not used to leave a location somewhere in the game why not allow that word as an alternative to the 'quit' command? While hopefully players won't be leaving your game so often that they get tired writing 'quit', allowing the abbreviation 'q' is pretty traditional. Fortunately for the game author, you don't need to define extra commands called 'exit' and 'q' but simply list those words as alternatives for 'quit' in a 'synonyms' statement.
SYNONYMS q = 'quit'. 'exit' = 'quit'.
(Note that because exit is an Alan keyword - used to define exits from locations - it must be put in quotemarks when we define it as a player-enterable word. The letter q has no special meaning in the Alan language so quote-marks are not required.)
Synonyms can be defined for any word a player might type while playing a game. Defining abbreviations for direction commands are probably the most helpful because they will probably be the commands players most frequently type.
SYNONYMS n = north. s = south.
(Note that, as in the example above, you can list the synonyms for more than one command in one synonym statement. I prefer to define synonyms for each verb with its own separate synonym statement next to the verb's syntax statement. I find it easier to keep track of things that way.)
Its probably worth noting here that EXIT
names don't have to be compass directions. You could define exits called up, in, exit or shazam for example.
VISITS
Statement Like synonyms, another feature that often improves the playing experience is to not redisplay a location description when the player revisits a location.
By default, Arun always displays the location description. The game author can change this by using the VISITS
statement. If VISITS 99
(or any other big number) appears in the START
section of a game, after the initial visit, a location description won't be redisplayed until the player has revisited that location 99 times - effectively it will never be redisplayed.
START AT Street. VISITS 99.
LOOK
Statement At some point after the initial visit the player may want to see the location description again. The LOOK
statement prints the description of the current location so we can create a verb containing the LOOK
statement so the player can redisplay a location's description whenever they wish. Like the quit and score verbs, the look verb name and Alan statement the verb executes will be the same so we have to put single quote-marks around the verb name.
VERB 'look' DOES LOOK. END VERB.
Also, because it is a single-word verb we need a SYNTAX
statement to tell Alan that the verb makes sense on its own. And, as it will be a commonly used command players will appreciate it if we defining an abbreviation with a synonym statement.
SYNTAX 'look'='look'. SYNONYMS l='look'.
Players may not always want VISITS
set to 99. At times they may want the location description displayed every time they visit a location. This setting in a text adventure game is traditionally called 'verbose' mode. The opposite is known as 'brief' mode.
We can define brief and verbose verbs to let the player switch between the two modes as they wish. The verbs will execute a visits
0 and a visits
99 statement respectively.
VERB brief DOES VISITS 99. END VERB. VERB verbose DOES VISITS 0. END VERB.
Note that single-quote marks aren't required around the brief and verbose verb names because they are not Alan keywords.
Of course, syntax definitions are required for both the brief and verbose verbs because they are single-word commands. A few synonyms might also be appreciated by the player. So we need something like this in our source code:
SYNTAX verbose=verbose. SYNTAX brief=brief. SYNONYMS short=brief. full=verbose.
Verbs can display text as well as executing Alan statements. This is simply done by putting the required text (inside double-quote marks) in the DOES
section of the verb definition.
To display a brief or verbose mode confirmation when the player uses the brief and verbose verbs we could modify the verb definitions like this:
VERB brief DOES VISITS 99. "$pDescriptions will only be displayed the first time you visit a location$p" END VERB. VERB verbose DOES VISITS 0. "$pDescriptions will be displayed each time you visit a location$p" END VERB.
It can be a bit confusing when to use double or single quote-marks in your Alan source code.
The text that will be displayed on screen during the play of a game (such as location descriptions) should be written within double quote marks in the source code. Remember, double-quoted strings are actually 'print-this-text' Alan statements - PRINT
statements with the word PRINT
left out.
Single-quote marks around the names of locations and verbs etc are used in the source code to distinguish those names from Alan keywords that happen to be spelt the same.