| 2.1. Varying What Is Written |
Before getting to actual recipes, many recipe books begin with intimidating lists of high-end kitchen equipment (carbon-steel pans, a high-temperature range, a Provencal shallot-grater, a set of six pomegranate juicers): fortunately, readers who have downloaded Inform already have the complete kitchen used by the authors. But the other traditional preliminaries, about universal skills such as chopping vegetables, boiling water and measuring quantities, do have an equivalent.
For us, the most basic technique of IF is to craft the text so that it smoothly and elegantly adapts to describe the situation, disguising the machine which is never far beneath the surface. This means using text substitutions so that any response likely to be seen more than once or twice will vary.
M. Melmoth's Duel demonstrates three basic techniques: an ever-changing random variation, a random variation changing only after the player has been absent for a while, and a message tweaked to add an extra comment in one special case. (Random choices can be quite specifically constrained, as Ahem shows in passing.) Fifty Ways to Leave Your Larva and Fifty Times Fifty Ways show how a generic message can be given a tweak to make it a better fit for the person it currently talks about. Curare picks out an item carried by the player to work into a message, trying to make an apt rather than random choice. Straw Into Gold demonstrates how to have Inform parrot back the player's choice of name for an object.
Another reason to vary messages is to avoid unnatural phrasing. Odins carefully avoids a giveaway grammatical blunder - the kind only a computer would make. Ballpark turns needlessly precise numbers - another computerish trait - into more idiomatic English. (Likewise Numberless, though it is really an example demonstrating how to split behaviour into many cases.) Prolegomena shows how to use these vaguer quantifiers any time Inform describes a group of objects (as in "You can see 27 paper clips here.").
Blink, a short but demanding example from the extreme end of Writing with Inform, shows how the basic text variation mechanisms of Inform can themselves be extended. Blackout demonstrates text manipulation at a lower level, replacing every letter of a room name with "*" when the player is in darkness.
A few of Inform's included extensions provide extra control over text output, as well: Complex Listing allows us more control over the order and presentation of lists of items, and Plurality provides functions for handling pronouns and objects whose names might be understood as singular or plural.
The extension Case Management used to be used for changing the case of something printed, but it is now included chiefly to support older Inform projects: now the best way to change printed text to upper, lower, sentence, or title casing is to use indexed text, as demonstrated in Rocket Man.
| Example Ahem Writing a phrase, with several variant forms, whose function is to follow a rule several times. | |
| Example Curare A phrase that chooses and names the least-recently selected item from the collection given, allowing the text to cycle semi-randomly through a group of objects. | |
| Example Odins Making [is-are] and [it-they] say tokens that will choose appropriately based on the last object mentioned. | |
The faithful reader may recall this example from the previous chapter. It was always a bit flawed, though, because it didn't account very well for the possibility that our game might contain some intrinsically plural items. Here we define a "to say is-are" ability, checking the appropriate either/or property - "plural-named".
"Odins"
The House of a Mortal Farmer is a room. "Having two separate rooms, this house testifies to considerable wealth and success at agriculture."
The Bedroom is inside from the House.
A chair is a kind of supporter. A chair is always enterable.
In the House are a table, two chairs, a basket, and a hearth. On the table is a loaf of bread. Some shoes are on the table.
The description of a thing is usually "You give [the noun] a glance, but [it-they] [is-are] plainly beneath your attention."
The infant is a man in the basket. The description of the infant is "So strong and fat that you wonder whether one of your fellow gods is acquainted with the mistress of the house-- but it's no concern of yours, of course."
The last mentioned thing is a thing that varies.
After printing the name of something (called the target):
now the last mentioned thing is the target.
To say is-are:
if the last mentioned thing is plural-named, say "are";
otherwise say "is".
To say it-they:
if the last mentioned thing is plural-named, say "they";
otherwise say "it".
Test me with "x chair / x basket / x infant / x shoes".
|
| Example Numberless A simple exercise in printing the names of random numbers, comparing the use of "otherwise if...", a switch statement, or a table-based alternative. | |
| Example Prolegomena Replacing precise numbers with "some" or other quantifiers when too many objects are clustered together for the player to count at a glance. | |
| Example Blink Making a "by atmosphere" token, allowing us to design our own text variations such as "[one of]normal[or]gloomy[or]scary[by atmosphere]". | |