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".
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".
Suppose we want to ask the player a question where he might say yes or no in response. There are two possible forms of this: the modal question where the player must pick one to proceed, and the non-modal question where he might also type other verbs.
"Proposal"
The story genre is "A Worked Example about Yes/No Questions".
Section 1 - Asking a Modal Yes/No Question
When play begins:
say "Do you like Mr Spruce? ";
if player consents, now Spruce is handsome;
otherwise now Spruce is ugly;
say paragraph break.
Section 2 - Mr Spruce's Non-Modal Question
Use full-length room descriptions.
The Conservatory is a room. "You are in a room full of plants."
Mr Spruce is a man in the Conservatory. Mr Spruce can be apprehensive or calm. Mr Spruce is calm. Mr Spruce can be handsome or ugly.
At 9:02 AM: say "Mr Spruce flings himself to his knees and implores you to become his lawfully wedded wife.";
now Mr Spruce is apprehensive;
Mr Spruce gives up in two minutes from now.
At the time when Mr Spruce gives up:
say "Mr Spruce sighs heavily, seeing that you don't intend to reply. 'Never mind, my dear, I'll ask later. Perhaps I should have spoken to your Papa first... yes, a gently-bred female... no wonder...'";
now Mr Spruce is calm;
Mr Spruce departs in one minute from now.
At the time when Mr Spruce departs:
if the player can see Mr Spruce, say "Mr Spruce takes his leave of you.";
otherwise say "Mr Spruce pokes his head in to say that he is leaving.";
end the story saying "Well, that is over..."
Instead of saying yes in the presence of an ugly apprehensive Mr Spruce:
now Mr Spruce is calm;
say "Remembering what your mother said to you about the stock exchange and Dear Papa, you close your eyes and accept Mr Spruce.";
end the story saying "Alas for your maiden hopes."
Instead of saying yes in the presence of a handsome apprehensive Mr Spruce:
now Mr Spruce is calm;
say "You are silent with delight for a moment before you say yes, yes!";
end the story saying "How Genevieve Stubbs will cry!"
Instead of saying no in the presence of an ugly apprehensive Mr Spruce:
now Mr Spruce is calm;
say "Gently you inform Mr Spruce that it is impossible. He seems less deflated than you had expected.";
end the story saying "Odd, that..."
Instead of saying no in the presence of a handsome apprehensive Mr Spruce:
now Mr Spruce is calm;
say "You lower your eyes and refuse petulantly, hoping to stir him to a more ardent repetition of these same requests. But then -- alack! -- he says 'I see how it is!' in a strangled voice, and strides from the room!";
end the story saying "A fatal error!"
And since the player might SAY YES TO SPRUCE, we had better reroute the relevant options:
Instead of answering Mr Spruce that "no", try saying no.
Instead of answering Mr Spruce that "yes", try saying yes.
Instead of asking Mr Spruce to try saying yes, try saying yes.
Instead of asking Mr Spruce to try saying no, try saying no.
Instead of saying sorry, try saying no.
Instead of asking Mr Spruce to try saying sorry, try saying no.
Instead of answering Mr Spruce that "sorry", try saying no.
Test me with "z / z / z / yes".
Test more with "z / z / z / no".
By default, ASK SOMEONE ABOUT... applies only to a text token. We might want also to offer the player the option of asking characters about pieces of physical evidence. This example implements an ASK PERSON ABOUT THING command that is mostly synonymous with SHOW, with the added nuance that the player can ask about things that are not currently visible, as long as he has encountered them at some time in the past.
"Nameless"
The Black Chamber is a room. "Despite its menacing name, it is quite an ordinary room, underlying the post office above. Here letters are brought each day, unsealed, transcribed, resealed, and sent again on their way; their contents then analyzed and recorded."
The Nameless Advisor is a woman in the Black Chamber. "A woman whose name has never been disclosed to you sits at the window, writing numbers on a sheet of paper." The Advisor carries a sheet of paper. Understand "woman" as the nameless advisor.
The player carries a letter from the emperor. The description of the letter is "Though its origin is obvious, its meaning is secret: the letters are an inexplicable jumble."
Now we create our new action, "interrogating it about". We write the grammar lines so that we can show any object in sight to someone, but also ask someone about any object that we have ever interacted with in the game, whether it is currently visible or not.
A thing can be known or unknown. The Nameless Advisor is known.
Understand "ask [someone] about [any known thing]" as interrogating it about. interrogating it about is an action applying to two visible things.
Now we replace and redirect the showing action. This gets rid of the requirement in the default library that the player be holding anything he shows to another character:
Understand the commands "show" and "display" and "present" as something new.
Understand "show [something] to [someone]" or "display [something] to [someone]" or "present [something] to [someone]" as interrogating it about (with nouns reversed). Understand "show [someone] [something]" as interrogating it about.
This bit keeps track of what the player has seen, for the purposes of "any known thing":
Before printing the name of something (called the target): now the target is known.
Here we define what happens by default when we interrogate someone about something; we use the same response we get to asking someone about something that isn't otherwise interesting:
Carry out interrogating someone about something:
say "There is no reply."
Now redirect all asking to a topic table, and all interrogating to an object table:
Instead of asking Nameless Advisor about a topic listed in the Table of Nameless Advisor Topics:
say "[reply entry][paragraph break]".
Instead of interrogating Nameless Advisor about an item listed in the Table of Nameless Advisor Items:
say "[reply entry][paragraph break]".
Table of Nameless Advisor Items
item
|
reply
|
letter
|
"'It is enciphered,' she remarks[if the advisor can see the letter], glancing over the contents[otherwise], after you have offered a detailed description[end if]. 'A substitution cipher of some complexity, I believe.'"
|
Advisor
|
"She listens to your inquiries about her identity and parentage with a placid smile, but does not answer."
|
Table of Nameless Advisor Topics
topic
|
reply
|
"cipher"
|
"'I know many dozens of ciphers,' she replies, smiling in a disquieting way."
|
"substitution cipher"
|
"'One letter is allowed to stand for another,' she explains, folding her hands together patiently. The backs of both hands are tattooed with silvery stars."
|
And just so that we can test what happens when asking someone about something out of sight:
The safe box is a container in the Chamber. It is fixed in place. It is openable and closed.
...and something unknown:
The poisonous apple is a thing.
Test me with "test sight / test knowledge".
Test sight with "i / x letter / ask Nameless Advisor about cipher / show cipher to Nameless Advisor / ask Nameless Advisor about the letter / show the letter to Nameless Advisor / show Nameless Advisor the letter".
Test knowledge with "open safe box / put letter in safe box / close safe box / ask Nameless Advisor about the letter / show the letter to Nameless Advisor / ask Nameless Advisor about the apple".