Inform 7 Home Page / Documentation
Chapter 5: Text
§5.1. Text with substitutions; §5.2. How Inform reads quoted text; §5.3. Text which names things; §5.4. Text with numbers; §5.5. Text with lists; §5.6. Text with variations; §5.7. Text with random alternatives; §5.8. Line breaks and paragraph breaks; §5.9. Text with type styles; §5.10. Accented letters; §5.11. Unicode characters; §5.12. Displaying quotations; §5.13. Making new substitutions
Contents of Writing with Inform | |
Chapter 4: Kinds | |
Chapter 6: Descriptions | |
Indexes of the examples |
§5.1. Text with substitutions
In the previous chapter, we gave properties to certain kinds of things in order to change their appearance and behaviour, and saw brief glimpses of one of Inform's most useful devices: text substitution. The following gives a more complete example:
A dead end is a kind of room with printed name "Dead End" and description "This is a dead end. You'll have to go back the way you came, consoled only by [river sound]." A dead end is usually dark.
The Undertomb is a dark room. East is a dead end. South is a dead end with printed name "Collapsed Dead End". Northwest is a dead end called the Tortuous Alcove. In the Undertomb is the lantern. It is lit.
A dead end has some text called river sound. The river sound of a dead end is usually "a faint whispering of running water". The Tortuous Alcove has river sound "a gurgle of running water".
The novelty here is the text in square brackets in the first paragraph. They imply more or less what they would when a journalist is quoting something in a newspaper article. The actual words "river sound" are not part of the text. Instead, when Inform prints up the description of a dead end, it will substitute the appropriate river sound in place of these words.
Thus the description of the Collapsed Dead End is "This is a dead end. You'll have to go back the way you came, consoled only by a faint whispering of running water.", whereas the description of the Tortuous Alcove is "This is a dead end. You'll have to go back the way you came, consoled only by a gurgle of running water." As the player explores these dead ends, subtle differences will appear in their room descriptions.