Sometimes we do not particularly want to deal with all the variations on asking, telling, or answering someone something, but want to direct everything to a single conversational command:
"Consulting the Oracle"
The Grove is a room. In the Grove is a woman called the Sybil.
Instead of telling someone about something, try asking the noun about it. Instead of answering the noun that something, try asking the noun about it.
Instead of asking the Sybil about "persians", say "She nods gravely."
And similarly, a difference between GIVE and SHOW is sometimes overkill:
Instead of showing something to someone, try giving the noun to the second noun.
The player carries a coin. Instead of giving the coin to the Sybil: move the coin to the Sybil; say "She accepts with a smile."
It is also often the case that we want to accept more than one form of a term. For instance
Instead of asking the Sybil about "Darius/king", say "Her smile unnerves you."
will match either "Darius" or "king". If necessary, we can go a step further and define our own token to match a variety of phrases, like this:
Understand "Athenians/Spartans/Greeks" or "hoplite army/forces" as "[Greeks]". Instead of asking the Sybil about "[Greeks]", say "She looks encouraging."
The token "[Greeks]" will match all of "Athenians", "Spartans", "Greeks", "hoplite army", or "hoplite forces". It will not match "hoplite" or "forces" alone; it is important to note that the / divides individual words which are understood equivalently, but does not define entire phrases as equivalent. More about how Inform understands specific phrases can be found in the chapter on Understanding.
Test me with "test one / test two".
Test one with "ask sybil about persians / tell sybil about persians / sybil, persians / ask sybil about darius / ask sybil about king".
Test two with "ask sybil about greeks / ask sybil about athenians / ask sybil about hoplite army / ask sybil about hoplite forces / give the coin to the sybil".
Occasionally we will want to replace the player's question topic with another of our own devising. We can do this in the simplest possible case like so:
"Lucy"
The International Boardgame Championship is a room. Lucy is a woman in the Championship.
Instead of asking Lucy about "checkers":
try asking Lucy about "games".
Instead of asking Lucy about "games",
say "'I don't like games,' she sniffs."
Test me with "ask lucy about checkers / ask lucy about games".
Note that this syntax did not work in older versions of Inform; it is now safe.
Inform already understands YES, NO, and SORRY as commands in their own right, which can make things a little sticky when we want a character to ask a question of the player. The most important thing is not to cover some of the possible phrasings while ignoring others.
"Replies"
The Grove is a room. In the Grove is a woman called the Sybil.
Instead of asking the Sybil to try saying no: try saying no. Instead of asking the Sybil to try saying yes: try saying yes. Instead of asking the Sybil to try saying sorry: try saying sorry.
Instead of answering the Sybil that "yes", try saying yes. Instead of answering the Sybil that "no", try saying no. Instead of answering the Sybil that "sorry", try saying sorry.
Instead of saying yes in the presence of the Sybil:
say "She looks interested."
Instead of saying no in the presence of the Sybil:
say "She looks annoyed."
Instead of saying sorry in the presence of the Sybil:
say "She looks bored."
The complexity arises from the fact that we want to handle both YES and SYBIL, YES. If we only had the latter, 'yes' would be treated as a text given to the Sybil, just as in the commands SAY YES TO SYBIL or ANSWER YES. But because we have defined it as a command (so that the player can use it independently), SYBIL, YES is understood as an order to the Sybil to do the YES action.
Fortunately, we can redirect everything, as here, so that the results wind up the same.
And if we want yet another variation not covered by the Inform standard:
Understand "tell [someone] [text]" as answering it that. Understand "tell [someone] that [text]" as answering it that.
But that is a matter for a later chapter.
Test me with "yes / sybil, yes / say yes to sybil / answer yes / tell sybil yes / no / sybil, no / say no to sybil / answer no / tell sybil no / sorry / sybil, sorry / say sorry to sybil / answer sorry / tell sybil sorry".
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".