| 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. | |
| 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. | |
Room descriptions often make the player character out to be a bit of a savant, able to count whole stacks of items at a glance: "You see 27 paper clips here."
We can adjust this behavior to our liking, though, with the printing a number... activity, as follows:
"Prolegomena"
The Editor's Office is a room. The desk is a supporter in the Editor's Office.
A red pencil is a kind of thing. 12 red pencils are on the desk.
A letter is a kind of thing. 12 letters are on the desk. Understand "correspondence" as a letter.
Rule for printing the plural name of a letter:
if the listing group size is greater than 7, say "correspondence";
otherwise say "letters".
Rule for printing a number of something (called the target) when the listing group size is greater than 7:
say "[one of]some [or]various [or]an assortment of [at random]";
carry out the printing the plural name activity with the target.
This general rule can of course be overridden by more specific ones; for instance, if we want to take the opportunity to comment on the viewpoint character's appetite for instruments of correction:
Rule for printing a number of red pencils (called the target) when the listing group size is greater than 10:
carry out the printing the plural name activity with the target;
say " in nearly-sufficient quantity".
Test me with "get two letters / look / get a pencil / i / get pencil / g / g / look / i / get all / i".
|
| 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]". | |