Chapter 17: Understanding

§17.1. Understand; §17.2. New commands for old grammar; §17.3. Overriding existing commands; §17.4. Standard tokens of grammar; §17.5. The text token; §17.6. Actions applying to kinds of value; §17.7. Understanding any, understanding rooms; §17.8. Understanding names; §17.9. Understanding kinds of value; §17.10. Commands consisting only of nouns; §17.11. Understanding values; §17.12. This/that; §17.13. New tokens; §17.14. Tokens can produce values; §17.15. Understanding things by their properties; §17.16. Understanding things by their relations; §17.17. Context: understanding when; §17.18. Changing the meaning of pronouns; §17.19. Does the player mean...; §17.20. Understanding mistakes; §17.21. Precedence

arrow-up-left.pngContents of Writing with Inform
arrow-left.pngChapter 16: Tables
arrow-right.pngChapter 18: Activities
arrow-down-right.pngIndexes of the examples

§17.1. Understand

During play, the computer and the player alternate in writing messages to each other: in the player's case, these are short instructions, usually saying what to do next. A wide range of such "commands" are automatically understood, but these only apply to the standard built-in actions. (This wide range is conveniently tabulated at the foot of the Actions index.) If we want the player to be able to command new actions, then we need to specify what is to be understood as what. For this, we supply special sentences starting with the word "Understand".

Suppose we return to the earlier example of a newly created action:

Photographing is an action applying to one visible thing and requiring light.

We then supply lines of grammar (as they are called) for Inform to recognise, like so:

Understand "photograph [someone]" as photographing.

Understand "photograph [an open door]" as photographing.

As usual, the square brackets indicate something which stands for text, rather than text to be taken verbatim. "[someone]" needs to be the name of anything of the kind "person", for instance (though as usual that person will need to be in sight of the player for the name to be accepted). The first word - in these examples "photograph" - must be something definite, not a substitution like this.

For obvious reasons, this pattern of words needs to match the expectations of the action. Photographing applies to "one visible thing" - the "visible" just means it does not need to be touched, only seen - so neither of these would be allowable:

Understand "photograph" as photographing.
Understand "photograph [someone] standing next to [something]" as photographing.

The first is probably bad because it supplies no things at all, the second is certainly because it supplies two: what we want, of course, is just the one. (The reason the first is only probably bad is that it's possible to tell Inform how to choose the object if the player doesn't: see the "supplying a missing noun" activity.)


arrow-up.pngStart of Chapter 17: Understanding
arrow-left.pngBack to Chapter 16: Tables: §16.19. Table amendments
arrow-right.pngOnward to §17.2. New commands for old grammar

*ExampleIndirection
Renaming the directions of the compass so that "white" corresponds to north, "red" to east, "yellow" to south, and "black" to west.

*ExampleXYZZY
Basics of adding a new command reviewed, for the case of the simple magic word XYZZY.

If we wanted to define a brand new verb that did affect a specific object, we might begin like this:

paste.png "Xylan"

Understand "hydrolyze [something]" as hydrolyzing. Hydrolyzing is an action applying to one thing.

Carry out hydrolyzing:
    say "[The noun] cannot be hydrolyzed."

Instead of hydrolyzing the xylan:
    move the xylose to the holder of the xylan;
    now the xylan is nowhere;
    say "At once the xylan becomes xylose."

Plant Cell Wall is a room.

There is a xylose sample. The xylan sample is a thing in Plant Cell Wall. The description of the xylan is "A polysaccharide. Totally useless. If only you had some xylose, instead!" The description of the xylose is "Awesome!"

Test me with "x xylan / hydrolyze xylan / x xylose".

Of course, how our players will ever solve this problem is another question (especially if their biology and chemistry are both rusty). When adding entirely new commands to a game, it is often a good idea to provide as many ways of phrasing the command as possible; to drop hints about the correct phrasing within the game's text; or even to tell the player about the expanded command list in some documentation or help at the beginning of the game. So for instance we might also add

Understand "break down [something] with water" or "break [something] down with water" as hydrolyzing.

And these lines will also provide syntax for our new command, without interfering with the previous syntax. It's also good to anticipate alternative (British or American) spellings. People's typing habits are hard to overcome, even if they know you are spelling the word the other way. It is probably best not to annoy them unduly. So:

Understand "hydrolyse [something]" as hydrolyzing.

Then some text in-game might offer a clue, subtle or (since this is an example) blunt:

Instead of examining the player, say "You're a drop of water, which means that you can break down certain chemicals!"

Understand "break down [something]" or "break [something] down" as hydrolyzing.

And finally, we could try adding instructions explicitly:

Understand "help" or "hint" or "hints" or "instructions" or "info" or "about" as asking for help. Asking for help is an action out of world. Carry out asking for help: say "The following commands are understood, in addition to the standard ones: EVAPORATE, FREEZE, HYDROLYZE, SUBLIME..."

Test more with "help / x me / break down xylan"

...though of course in fact these other commands won't be available until we define them, too.

This last approach, defining all the extra commands up front, is especially useful if these commands are very technical or unusual; if they are needed early in the game, before you've a chance to educate the player; or if they are not suggested by any in-game objects. A player who encounters a tool with an obvious use, such as a hairbrush, will likely think of trying to BRUSH things with it. It's harder to rely on his guessing actions that are both outside the range of usual commands and unrelated to any of the visible props, however.

**ExampleXylan
Creating a new command that does require an object to be named; and some comments about the choice of vocabulary, in general.

If we wanted to define a brand new verb that did affect a specific object, we might begin like this:

paste.png "Xylan"

Understand "hydrolyze [something]" as hydrolyzing. Hydrolyzing is an action applying to one thing.

Carry out hydrolyzing:
    say "[The noun] cannot be hydrolyzed."

Instead of hydrolyzing the xylan:
    move the xylose to the holder of the xylan;
    now the xylan is nowhere;
    say "At once the xylan becomes xylose."

Plant Cell Wall is a room.

There is a xylose sample. The xylan sample is a thing in Plant Cell Wall. The description of the xylan is "A polysaccharide. Totally useless. If only you had some xylose, instead!" The description of the xylose is "Awesome!"

Test me with "x xylan / hydrolyze xylan / x xylose".

Of course, how our players will ever solve this problem is another question (especially if their biology and chemistry are both rusty). When adding entirely new commands to a game, it is often a good idea to provide as many ways of phrasing the command as possible; to drop hints about the correct phrasing within the game's text; or even to tell the player about the expanded command list in some documentation or help at the beginning of the game. So for instance we might also add

Understand "break down [something] with water" or "break [something] down with water" as hydrolyzing.

And these lines will also provide syntax for our new command, without interfering with the previous syntax. It's also good to anticipate alternative (British or American) spellings. People's typing habits are hard to overcome, even if they know you are spelling the word the other way. It is probably best not to annoy them unduly. So:

Understand "hydrolyse [something]" as hydrolyzing.

Then some text in-game might offer a clue, subtle or (since this is an example) blunt:

Instead of examining the player, say "You're a drop of water, which means that you can break down certain chemicals!"

Understand "break down [something]" or "break [something] down" as hydrolyzing.

And finally, we could try adding instructions explicitly:

Understand "help" or "hint" or "hints" or "instructions" or "info" or "about" as asking for help. Asking for help is an action out of world. Carry out asking for help: say "The following commands are understood, in addition to the standard ones: EVAPORATE, FREEZE, HYDROLYZE, SUBLIME..."

Test more with "help / x me / break down xylan"

...though of course in fact these other commands won't be available until we define them, too.

This last approach, defining all the extra commands up front, is especially useful if these commands are very technical or unusual; if they are needed early in the game, before you've a chance to educate the player; or if they are not suggested by any in-game objects. A player who encounters a tool with an obvious use, such as a hairbrush, will likely think of trying to BRUSH things with it. It's harder to rely on his guessing actions that are both outside the range of usual commands and unrelated to any of the visible props, however.

If we wanted to define a brand new verb that did affect a specific object, we might begin like this:

paste.png "Xylan"

Understand "hydrolyze [something]" as hydrolyzing. Hydrolyzing is an action applying to one thing.

Carry out hydrolyzing:
    say "[The noun] cannot be hydrolyzed."

Instead of hydrolyzing the xylan:
    move the xylose to the holder of the xylan;
    now the xylan is nowhere;
    say "At once the xylan becomes xylose."

Plant Cell Wall is a room.

There is a xylose sample. The xylan sample is a thing in Plant Cell Wall. The description of the xylan is "A polysaccharide. Totally useless. If only you had some xylose, instead!" The description of the xylose is "Awesome!"

Test me with "x xylan / hydrolyze xylan / x xylose".

Of course, how our players will ever solve this problem is another question (especially if their biology and chemistry are both rusty). When adding entirely new commands to a game, it is often a good idea to provide as many ways of phrasing the command as possible; to drop hints about the correct phrasing within the game's text; or even to tell the player about the expanded command list in some documentation or help at the beginning of the game. So for instance we might also add

Understand "break down [something] with water" or "break [something] down with water" as hydrolyzing.

And these lines will also provide syntax for our new command, without interfering with the previous syntax. It's also good to anticipate alternative (British or American) spellings. People's typing habits are hard to overcome, even if they know you are spelling the word the other way. It is probably best not to annoy them unduly. So:

Understand "hydrolyse [something]" as hydrolyzing.

Then some text in-game might offer a clue, subtle or (since this is an example) blunt:

Instead of examining the player, say "You're a drop of water, which means that you can break down certain chemicals!"

Understand "break down [something]" or "break [something] down" as hydrolyzing.

And finally, we could try adding instructions explicitly:

Understand "help" or "hint" or "hints" or "instructions" or "info" or "about" as asking for help. Asking for help is an action out of world. Carry out asking for help: say "The following commands are understood, in addition to the standard ones: EVAPORATE, FREEZE, HYDROLYZE, SUBLIME..."

Test more with "help / x me / break down xylan"

...though of course in fact these other commands won't be available until we define them, too.

This last approach, defining all the extra commands up front, is especially useful if these commands are very technical or unusual; if they are needed early in the game, before you've a chance to educate the player; or if they are not suggested by any in-game objects. A player who encounters a tool with an obvious use, such as a hairbrush, will likely think of trying to BRUSH things with it. It's harder to rely on his guessing actions that are both outside the range of usual commands and unrelated to any of the visible props, however.