The command parser

From ADRIFT 5 Manual Wiki
Jump to: navigation, search

When the player enters a new command, the words that they type are interpreted by a special program called a "Parser". The parser first separates out any special keywords (ALL, AND, EXCEPT, IT, THEM, HIM, HER) then tries to match the command to the command templates in all of the general tasks. The general tasks contain words which are directly matched to the players input, and references which tell the parser to try to match the players input to the name of an object, character or location. This matching is very flexible, and allows the player to only enter part of an objects name, or to refer to a character either by their name or their description.

One word commands

The simplest commands consist of a single noun. In the standard library this is only used for the most common commands such as moving in a particular direction or looking at your inventory, but you can add more of your own if you wish. As this is usually done to save typing for commands that the player is using regularly, these commands usually have a one or two character abreviation to simplify them even further.

> i
I am wearing a suit and am carrying a bouquet of flowers.

"i" is the abreviation for inventory, and lists everything the players character is wearing and carrying.

> ne
There is no route to the northeast, only north and south.

"ne" is the abreviation for walking to the northeast. If it is not possible to go in that direction, then ADRIFT will tell the player which directions they can move towards from their current location.

Verb + Noun commands

A verb followed by a noun is the most common type of command in interactive fiction. The nouns usually refer to objects or characters in the game. The commands that players can enter are described in general tasks, which contain a "command" field that describe all of the variations in the command that the player can type. These use references to indicate where in the command the player can type the name of an object or character. The most common references are "%object%" for the name of an object, and "%character%" for the name or description of a character.

> get briefcase
Ok, I take the briefcase.

The general task for this is "get %object%". The parser checks if "briefcase" is the name of an object and, when it confirms that it is, the "get" task is run.

> attack troll
I don't think the troll would appreciate that very much.

The troll is a character, so the parser looks for a task that contains the command "attack %character%".
  • The verb part can be several words if required, eg. "pick up briefcase" will match "pick up %object%" and "lay down on bed" will match "lay down on %object%"

More complex commands

ADRIFT allows commands of unlimited complexity to be described in a general task.

> put document in briefcase
Ok, I put the document in the briefcase.

The general task for this is "put %object1% in %object2%". The parser checks if "document" and "briefcase" are both the name's of objects and, when it confirms that they are, this task is run.

> give briefcase to susan
I hand susan the briefcase.

Susan is a character, so the parser looks for a task that contains the command "give %object% to %character%".
  • If you wanted to you could write extemely complex commands that contain references to up to 5 objects, 5 characters, a direction, a location, a number and a %text% reference that allows the player to type anything at all at that point in the command.

Special parser key-words

The following keywords are directly decoded by the parser to allow more complex commands to be entered than has been defined in the general tasks.

This allows for more natural commands to be entered, and enables the player to manipulate multiple objects with a single command.

ALL

The ALL keyword can be used anywhere an %object% reference appears in a command. It causes the tasks actions to be executed for every object that would pass the tasks restrictions. The output message of the task is then printed, using a list of those objects where it would normally print the name of a single object.

> get all
Ok, I pick up the floor mat, the red pen and the bouquet of flowers

get all will get every object in the current location that the player is allowed to take.

> drop all
Ok, I put down the floor mat, the red pen and the bouquet of flowers

drop all will drop everything in the players inventory.

AND

The AND keyword lets the player specify several items at once.

> get flowers and mat
Ok, I pick up the floor mat and the bouquet of flowers

Using AND you can perform the same command on two objects at once.

> get scarab, flowers and mat
Ok, I pick up the egyptian scarab, the floor mat and the bouquet of flowers

For more than two objects, separate them with comma's.

EXCEPT

The EXCEPT keyword is usually used with ALL to exclude one or two objects from a large group.

> get all except flowers and mat
Ok, I pick up the red pen, the blue pen and the egyptian scarab

Player gets everything except the objects he excludes.

IT

> get scarab
Ok, I pick up the egyptian scarab.
> x it
The egyptians used to wrap these inside mummy's for protection.

When a command refers to a specific object, ADRIFT stores a reference to that object and the next time the player uses the word "it", it is replaced with the name of that object.

THEM

> get chopsticks
Ok, I pick up some wooden chopsticks.
> x them
The chinese prefer to eat with these.

When a command refers to an object that has been defined with the article "some", ADRIFT stores a reference to that object and the next time the player uses the word "them", it is replaced with the name of that object. Note that the "it" and "them" objects are stored separately and will not refer to the same object.

HIM

> x pirate
He has a wooden leg and a patch over one eye.
> give gold coin to him
The pirate bites the coin to make sure its real, smiles at you, then saunters off.

When a command refers to a specific male character, ADRIFT stores a reference to that character and the next time the player uses the word "him", ADRIFT uses the name of that character.

HER

> x famous author
She is a young woman with long straight hair, wearing an ankle length red dress and carrying a heavy book that has her photo on the back.
> ask her about book
"This is for you" she says, handing it to you.

When a command refers to a specific female character, ADRIFT stores a reference to that character and the next time the player uses the word "her", ADRIFT uses the name of that character.

Disambiguation

Normally the player can refer to objects using just the noun part of their name, but if there are two or more objects that use the same noun (ie. a "red pen" and a "blue pen") then the player needs to enter the full name.

If they don't, then the ADRIFT parser will ask which one they want to use.

> get mat, pen and flowers
Which pen? The blue pen, the red pen or the green pen.
> red
Ok, i pick up the the floor mat, the red pen and the bouquet of flowers.

When the parser asks the player to disambiguate between similar objects they only need to enter the wanted objects adjective. ADRIFT then replaces "pen" with "red pen" in the original command and executes it.

Plurals

If there are several objects which use the same singular noun in their name, then the player can use the plural form of the noun to refer to all of them at once.

> get pens
Ok, I pick up the blue pen, the red pen and the green pen.

If there isn't an object called "pens" then ADRIFT will try to execute the command for every object that has "pen" as its noun.


<<< Getting StartedMain PageVerbs and Commands >>>