5.13. Making new substitutions

| Chapter 5: Text |

| 5.13. Making new substitutions

If we have some textual effect which needs to occur in several different messages, we might want to create a new text substitution for it. For instance:

> The Missile Base is a room. "[security notice]Seems to be a futuristic missile base." M's Office is east of the Missile Base. "[security notice]Admiral Sir M.- M.- glares up from his desk."

> To say security notice:
> say "This area is a Prohibited Place within the meaning of the Official Secrets Act 1939. "

This is only the tip of the iceberg in how to define ways to do things using "To...", as we shall see. The definition makes "say the security notice" a new phrase known to Inform. A text substitution is exactly a phrase whose name begins with "say" (well - except for the "say" phrase itself), so the effect is that "[security notice]" is a new text substitution. Several of the examples in this chapter make use of this trick.

Inform often ignores the casing of the text it reads, but sometimes uses it as a clue to meaning. We have already seen that "[an item]" and "[An item]" produce different results, for instance. Similarly, it's possible to define two text substitutions which are the same except for the initial casing. We might write:

> To say Security Notice:
> say "THIS AREA IS A PROHIBITED PLACE WITHIN THE MEANING OF THE OFFICIAL SECRETS ACT 1939. "

And now Inform will act on "[Security Notice]" differently from "[security notice]".

See The phrasebook for other forms of phrase besides To say...

71
| Example Fifty Ways to Leave Your Larva Using text substitution to make characters reply differently under the same circumstances. |
RB

We can use these substitutions to put together fairly complicated variations within a single piece of text: "Fifty Ways to Leave Your Larva" The Beekeeper's Palace is a room. Wasp is a woman in the palace. Drone is a man in the palace. Instead of kissing someone: say "'[denial], [insult]! [boast]!'"; In this context, [denial] is understood to refer to the denial property of the noun -- but we could spell it out with "denial of the noun" if we wanted to. A person has some text called denial. The denial of a person is usually "Stand back". The denial of Drone is "You forget yourself" A person has some text called insult. The insult of a person is usually "Grasshopper". The insult of Wasp is "Larva". A person has some text called boast. The boast of a person is usually "I am ferocious". The boast of Drone is "I have ferocious allies". And then it would be trivial to insert further rules using these responses: Instead of attacking someone: say "'Get away, [insult]!'" Test me with "kiss wasp / hit wasp / hit drone / kiss drone".

72
| Example Fifty Times Fifty Ways Writing your own rules for how to carry out substitutions. |
RB

Previous | Contents | Next