| 6.18. Alternatives To Standard Parsing |
Very occasionally, for out-of-the-ordinary games, we want to make major changes to the way that Inform ordinarily understands commands.
Cloves shows how we might read adverbs in the player's command: adverbs are challenging because they can legitimately appear anywhere in a command structure, so must be found and accounted for before the rest of the command is understood.
Fragment of a Greek Tragedy goes further, substituting a keyword-recognition parser for the usual structure of commands and objects.
Less drastically, menus of numbered options can temporarily replace or augment standard commands. Down in Oodville demonstrates how to add a list of transporter destinations from which the player may choose by numeral.
See Traits Determined By the Player for ways to ask the player a question at the beginning of play
See Saying Simple Things for a way to ask the player a yes-no question any time during play
|  Example Cloves Accepting adverbs anywhere in a command, registering what the player typed but then cutting them out before interpreting the command. | |
Apologies to the shade of A. E. Housman.
"Fragment of a Greek Tragedy"
Understand "restart/restore/save/quit" as "[meta-command]".
After reading a command:
if the player's command matches "[meta-command]", make no decision;
say line break;
repeat through Table of Current Topics:
if the player's command includes topic entry:
say "CHORUS: [reply entry][paragraph break]";
follow the advance time rule;
rule succeeds;
say "[italic type] Pause.[roman type][line break]";
follow the advance time rule;
rule succeeds.
Table of Current Topics
topic | reply |
"journey/trip/travel/came/arrived" | "Sailing on horseback, or with feet for oars?" |
"horseback/legs/feet/oars" | "Beneath a shining or a rainy Zeus?" |
"shining/rainy/weather/zeus" | "Mud's sister, not herself, adorns thy boots." |
This would be a bit bare if we didn't provide the player with some sort of context at the outset, so let's put some remarks before the first command prompt:
Before reading a command while the turn count is 1:
say "CHORUS: O suitably-attired-in-leather-boots
Head of a traveller, wherefore seeking whom
Whence by what way how purposed art thou come
To this well-nightingaled vicinity?
My object in inquiring is to know.
But if you happen to be deaf and dumb
And do not understand a word I say,
Then wave your hand, to signify as much."
This "turn count" condition is why it was useful to follow the advance time rule in "after reading a command": the game (or drama, if you like) will continue to count moves elapsed even though the rest of Inform's command parsing and world model is being ignored. In a longer and more ambitious implementation of this idea, we might want to allow scenes to govern the behavior and responses of the Chorus.
And then to give the whole exchange a play's format:
The Stage is a room.
The room description heading rule is not listed in the carry out looking rules.
When play begins:
now the command prompt is "YOU: ";
now left hand status line is "Fragment of a Greek Tragedy";
now right hand status line is "A. E. Housman".
(Because this example manipulates commands outside of the normal parser, the mechanism for TEST will not work here. Try typing commands such as: TELL CHORUS ABOUT JOURNEY / TELL CHORUS ABOUT FEET / TELL CHORUS ABOUT SHROPSHIRE / TELL CHORUS ABOUT ZEUS)
|
|  Example Down in Oodville Offering the player a choice of numbered options at certain times, without otherwise interfering with his ability to give regular commands. | |