Chapter 9: Props: Food, Clothing, Money, Toys, Books, Electronics
9.6. Reading Matter

Many things can be read, from warning notices to encyclopaedias, and a range of techniques is needed to provide them because the quantity of text, and how it presents itself, can vary so much. With a small amount of very large type, the player should not need any command at all to read the text:

The road sign is in the Junction. The road sign is fixed in place. "A road sign points north: 'Weston on the Green - 6'."

If the print is smaller, or the object portable, the player will expect to use the EXAMINE command:

The business card is in the Junction. The description is "'Peter de Sèvres: consultant mnemonicist.'"

But if the object is a leaflet, say, EXAMINE should only describe the cover: READ would be the command a player would expect to use to get at the text itself. Inform normally defines READ to be the same command as EXAMINE, which is good for things like the business card, but counter-productive here. The Trouble with Printing shows how to separate these two commands, allowing any thing to have a property called its "printing" for text produced by READ, which will be different from its "description", the text produced by EXAMINE.

If the object is a lengthy diary, say, nobody would read it from cover to cover in a single IF turn. We might then want to allow the player to turn the pages one by one, with commands like READ PAGE 4 IN DIARY or READ THE NEXT PAGE: see Pages.

If the object is an encyclopaedic reference work, the player would consult named entries: see Costa Rican Ornithology, which allows commands like LOOK UP QUETZAL IN GUIDE.

Still larger sources of text often occur in IF: libraries or bookshelves, where many books are found together, and it is clumsy to write them as many individual items. One approach is to simulate an entire bookshelf with a single thing: see Bibliophilia. (This is much like looking up topics in a single book, except that each topic is a book in itself.) Another is to provide each book as an individual item, but have them automatically join together into a single portable collection: see AARP-Gnosis.

Signs, leaflets and encyclopaedias, being printed, have a wording which will never change during play. But sometimes the player reads something which acts of its own accord. Text substitutions are usually all that is needed to achieve this:

The computer display is on the desk. The description is "Giant green digits read: [the time of day]."

This is easy because we know all the variations we want. But what if we want the player to write his own text, for instance, adding to a diary? This is trickier, because it means storing text as the player typed it, and replaying it later. (And suppose the player types reams and reams of text, not just a few words as we might have hoped?) The Fourth Body and The Fifth Body show how to use an external file - a multimedia trick requiring features only available if the project is set to the Glulx story file format - to handle even the most difficult cases.


94
*** Example  Costa Rican Ornithology
A fully-implemented book, answering questions from a table of data, and responding to failed consultation with a custom message such as "You flip through the Guide to Central American Birds, but find no reference to penguins."

WI

The following relies on quite a number of features we haven't met yet: tables, rules for printing names, instructions for understanding the player's commands. It is offered simply as an example of how a fully implemented book might be handled in Inform.

"Costa Rican Ornithology"

A book is a kind of thing. Understand "book" as a book. A book has a table name called the contents.

Instead of consulting a book about a topic listed in the contents of the noun:
    say "[reply entry][paragraph break]".

Report consulting a book about:
    say "You flip through [the noun], but find no reference to [the topic understood]." instead.

With this "topic understood" phrase, we're telling Inform to print back the word or phrase that the player was attempting to look up. This overrides the more general default response, "You discover nothing of interest in the book."

We now have the essential elements to construct whatever books we like. Now let's have an example of a specific book:

The Guide to Central American Birds is a book carried by the player. The contents of the Guide is the Table of Listed Birds.

We will come back to the idea of tables and table names later, but for now the important thing is that we have instructed Inform to look up its answers to consulting the bird guide in this form:

Table of Listed Birds
topic   reply   
"[red]" or "[red] bird/macaw"   "You flip through the Guide for a while and eventually discover a reference to the [scarlet macaw], which appears to correspond with what you see before you."   
"quetzal/trogon" or "resplendent trogon"   "The entry on the quetzal is quite lyrical, describing its brilliant plumage, flashing and igniting in the sunshine, which is supposedly sufficient to lure birdwatchers from all over the world. Unfortunately, the quetzal is described as being bright emerald in color, with a pink fuzz on its head and a long soft tail 'like a feather boa'. None of these describes your visitor."   

The topic column is a bit special: it matches the player's input, and is not meant to be printed out again. Topic columns will be discussed further in the chapter on Tables. (Note also that, however it may appear in the documentation, the topic column should not be spanning multiple lines in our source text.)

We may also compress long or complicated topics by creating bracketed abbreviations, and in fact it's useful to do so now, to explain the red token we just used:

Understand "red-orange" or "bird" or "red" or "orange" as the scarlet macaw. Understand "red-orange" or "red" or "orange" or "scarlet" as "[red]".

This technique is discussed further in the chapter on Understanding.

If we wanted more books, we could define those in the same way, giving each its own separate contents table to be used for consultation. But for the sake of the example we will keep it simple, and move on to the scenario itself:

The Veranda is a room. "From here you can see a considerable expanse of dense-growing jungle plants, and eventually the open water beyond."

The scarlet macaw is an animal in the veranda. "A vibrantly-colored [scarlet macaw] perches on the rail."

A thing can be known or unknown.

Before printing the name of the scarlet macaw while consulting:
    now the scarlet macaw is known.

Rule for printing the name of the unknown scarlet macaw: if the macaw is unknown, say "red-orange bird of unknown species".

Test me with "look up penguins in the guide / look up quetzal in guide / look up silver nuthatches in the guide / look / look up red bird in the book / look".

292
* Example  Pages
A book with pages that can be read by number (as in "read page 3 in...") and which accepts relative page references as well (such as "read the last page of...", "read the next page", and so on).

WI
313
** Example  Bibliophilia
A bookshelf with a number of books, where the player's command to examine something will be interpreted as an attempt to look up titles if the bookshelf is present, but otherwise given the usual response.

WI
322
** Example  AARP-Gnosis
An Encyclopedia set which treats volumes in the same place as a single object, but can also be split up.

WI
281
* Example  The Trouble with Printing
Making a READ command, distinct from EXAMINE, for legible objects.

WI
432
* Example  The Fourth Body
Notebooks in which the player can record assorted notes throughout play.

WI
433
** Example  The Fifth Body
An expansion on the notebook, allowing the player somewhat more room in which to type his recorded remark.

WI


PreviousContentsNext