![]() | Chapter 11: Phrases | ![]() ![]() |
11.14. Phrase options |
There are sometimes several slightly different ways to perform a given task but which have substantially the same definition. In the following example:
To go hiking, into the woods or up the mountain:
if into the woods, say "Watch out for badgers.";
if up the mountain, say "Better take your compass.";
say "You go hiking."
...a phrase has been set up which can be used in three ways:
go hiking;
go hiking, into the woods;
go hiking, up the mountain;
Note that commas must be used to divide these "phrase options" from the rest of the text of the phrase. Within the definition of the phrase, the option's name is a valid condition, and
if up the mountain, ...
tests whether it is set; we can also test if it is not set using:
if not up the mountain, ...
A more substantial example from the Standard Rules is given by a phrase used mostly for internal, technical reasons:
list the contents of (object)
This phrase produces a list of all things whose holder is the given object, according to Inform's traditional conventions for room descriptions and inventory listings. Example:
list the contents of Marley Wood, as a sentence, with newlines
Where this is possible, it's generally better to use "[list of things in ...]" instead, which produces the same result in an acceptable way for the middle of a sentence.
|
Note that this phrase is allowed to have multiple options specified, whereas "go hiking" above was not: this is because it was defined thus:
To list the contents of (something - an object), with newlines, indented, as a sentence, including contents, including all contents, giving inventory information, giving brief inventory information, using the definite article, listing marked items only, prefacing with is/are, not listing concealed items, suppressing all articles and/or with extra indentation: ...
The significant difference is the word "and/or" instead of "or", which signals that more than one option can apply at a time.
| ![]() ![]() Overview of all the phrase options associated with listing, and examples of how to change the inventory list into some other standard formats. |
|
Previous | Contents | Next |