Chapter 2: Adaptive Prose
§2.1. Varying What Is Written; §2.2. Varying What Is Read; §2.3. Using the Player's Input
![]() | Contents of The Inform Recipe Book |
![]() | Chapter 1: How to Use The Recipe Book |
![]() | Chapter 3: Place |
![]() | Indexes of the examples |
§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. 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.
Inform's included extension Complex Listing allows us more control over the order and presentation of lists of items.
For how to change printed text to upper, lower, sentence, or title casing, see Rocket Man.
![]() | Start of Chapter 2: Adaptive Prose |
![]() | Back to Chapter 1: How to Use The Recipe Book: §1.4. Information Only |
![]() | Onward to §2.2. Varying What Is Read |
|
|
The final "otherwise" here will fire only if none of the earlier conditions applies; we could leave it out and print nothing in the case that N is 4 or 5. The more compact way to do this is to create a list of values that our number could match; in many programming languages this is called a switch statement. For example:
As a final option, we can use a construction we've seen only briefly before now: a table. The use of tables will be explained more fully in their own chapter, but here we see in brief that we can assign a number of values to one column of a table and then use that table to look up output:
As we shall see, things other than text can be stored in tables, so we could also use a table as a way to look up objects or even rules to carry out. |
|
The final "otherwise" here will fire only if none of the earlier conditions applies; we could leave it out and print nothing in the case that N is 4 or 5. The more compact way to do this is to create a list of values that our number could match; in many programming languages this is called a switch statement. For example:
As a final option, we can use a construction we've seen only briefly before now: a table. The use of tables will be explained more fully in their own chapter, but here we see in brief that we can assign a number of values to one column of a table and then use that table to look up output:
As we shall see, things other than text can be stored in tables, so we could also use a table as a way to look up objects or even rules to carry out. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|