Inform 7 Home Page / Documentation
§9.10. Telephones
Telephones are much harder to achieve than televisions and in some ways as difficult to make convincing as a human character is - though of course there are corners which can be cut: we could have the reception drop off, or the other party hang up in a misunderstanding, and so on.
A single telephone line is tricky enough to provide that one might just as well have a general solution providing a whole network. Four Cheeses demonstrates a system where we can dial either people or numbers: CALL JANET ON TELEPHONE, or CALL 7103, for instance.
While Four Cheeses provides only four-digit phone numbers, like internal company extensions, Alias shows how to manage US-style seven digit numbers.
Finally, we might occasionally want the player to be able to address a microphone or telephone receiver directly when the identity of the person on the other end is unknown, in the form TELL MICROPHONE ABOUT CRIME. Ordinarily Inform will disallow this because we're not allowed to talk to inanimate objects, but the extension Inanimate Listeners provides more options.
See Saying Complicated Things for more approaches to conversation
Start of Chapter 9: Props: Food, Clothing, Money, Toys, Books, Electronics | |
Back to §9.9. Televisions and Radios | |
Onward to §9.11. Clocks and Scientific Instruments |
ExampleFour Cheeses |
A telephone is a kind of thing. Understand "phone" as a telephone.
Understand "call [any telephone] on [something]" as calling it on. Understand "call [any telephone]" as calling it on. Understand the commands "dial" or "phone" or "telephone" as "call". Understand "call [any known person]" as calling it by name on.
Connection relates one thing to another (called the other party).
Calling it on is an action applying to one visible thing and one thing.
Check calling it on:
if the second noun is not a telephone, say "[The second noun] is unlikely to be much use in that respect." instead;
if the second noun is the noun, say "You get a busy signal." instead.
Carry out calling it on:
if a person (called the listener) can see the noun, now the player reaches the listener.
Because we've said that connection is a reciprocal, one-to-one relationship, Inform will do the rest of the bookkeeping: if (for instance) we telephone someone else, the first connection will be broken automatically.
Report calling it on:
say "'Hello?' says [the other party of the player]."
To avoid annoyance, we should also let the player use CALL #### as well as CALL #### ON TELEPHONE. A rule from the chapter on Activities comes in handy here:
Rule for supplying a missing second noun while calling something on:
assign a phone.
To assign a phone:
if the player can touch a telephone (called the current phone):
say "(on [the current phone])[line break]";
now the second noun is the current phone;
otherwise:
say "You don't have a phone handy."
Things might be a little more complicated if we had cell phones that could be moved around, but for right now the player can only touch a maximum of one phone at a time.
Suppose we further want to allow the player to call people up by name, but only if they've already been encountered or are familiar to the player for some reason.
Understand "call [any known person]" as calling it by name on.
Understand "call [any known person] on [something]" as calling it by name on.
Rule for supplying a missing second noun while calling something by name on:
assign a phone.
Calling it by name on is an action applying to one visible thing and one thing.
Check calling it by name on:
if the noun is in the location, say "[The noun] is right here." instead.
Carry out calling it by name on:
if the noun can touch a telephone (called the link), try calling the link on the second noun;
otherwise say "You can't reach [the noun]." instead.
Before calling something on something when the player reaches someone:
say "(first ending your conversation with [the other party of the player])[command clarification break]";
end current conversation.
Check hanging up:
if the noun is not a telephone, say "You can't hang up [the noun]." instead;
if the player does not reach someone, say "You're not on the line with anyone." instead.
Report hanging up:
say "You put down [the noun], cutting the connection."
Before going somewhere when the player reaches someone:
say "(first hanging up on [the other party of the player])[command clarification break]";
end current conversation.
And finally we want to make sure that calling random other numbers produces a sensible result:
Understand "call [text]" as misdialling. Misdialling is an action applying to one topic. Carry out misdialling: say "The phone rings and rings but no one answers."
Understand "call 911" or "call 999" or "call police" or "call fire department" as a mistake ("After strict warnings, you've given up making prank calls to emergency services.").
Before misdialling when the player reaches someone:
say "(first ending your conversation with [the other party of the player])[command clarification break]";
end current conversation.
To end current conversation:
let the current phone be a random telephone which can be touched by the player;
silently try hanging up the current phone.
After deciding the scope of the player while the player reaches someone:
place the other party of the player in scope, but not its contents.
A note about this scope addition: the player can refer to the other party whenever he has the other person on the phone. He can't, however, see or refer to anything that person might be holding or wearing, thanks to the "but not its contents" option.
Furthermore, the player can't actually do anything to that person that requires touching. That's because of the reaching inside rules, which govern whether the player can reach through intervening barriers such as rooms. (See the Advanced Actions chapter for more about changing reachability.) There are two things we might want to be careful about, though.
First, we should specifically disallow the player from looking at the person on the other end of the line. Since sight doesn't require touching, the reaching inside rules will not be consulted about a command such as EXAMINE BOSS or LOOK UNDER BOSS. We can, however, intervene in such cases using the visibility rules, which are consulted for any actions that "require light" (including EXAMINE and LOOK UNDER). Here again we borrow some options from the Advanced Actions chapter:
To decide whether acting through the line:
if the noun is something and the location of the noun is not the location of the player:
yes;
if the second noun is something and the location of the second noun is not the location of the player:
yes;
no.
Visibility rule when acting through the line:
there is insufficient light.
Rule for printing a refusal to act in the dark when acting through the line:
say "You're not on a video phone, so you can only hear." instead.
Second, though the existing reaching inside rules are adequate to stop us from touching the person on the other end of the line, the response that's currently printed is a bit generic: it just says "You can't reach into [the room containing the person]." Let's add our own custom reply, instead:
A rule for reaching inside a room (called destination):
if the other party of the player is enclosed by the destination:
say "Though you're on the line with [the other party of the player], you can't physically reach to [the destination].";
deny access.
This portion supplies a simple method of conversation; but we could substitute some completely different conversation system if appropriate. The effect of the telephones is that we are allowed to talk to characters in distant locations under certain circumstances, after which the usual conversation rules apply.
Instead of listening to a telephone when the player reaches someone:
say "You can hear [the other party of the player] breathing."
Before listening to someone when the player cannot touch the noun:
say "[The noun] is waiting for you to carry on the conversation." instead.
Before telling someone about something:
try asking the noun about it instead.
Before answering someone that something:
say "Best to confine your conversation to questions and answers." instead.
Before asking someone about something:
if the topic understood is a topic listed in the chatter of the noun, say "[reply entry][paragraph break]" instead;
otherwise say "[The noun] does not reply." instead.
The Guard House is a room. "Here you spend all your nights. Bullet-proof windows offer a panoramic view of serene cliffs, palm trees, and a moonlit ocean. Occasionally someone is foolish enough to try a cliff ascent or even an attack by helicopter, but lately things have been pretty quiet.
The mansion is up the hill behind you, security lights ablaze."
The grey telephone is a telephone in the Guard House. Understand "6885" as the grey telephone. "Before you is a grey telephone. In black marker someone has written on it: MAIN OFFICE 2802."
Before going a direction in the Guard House, say "And leave your post? The boss would have you flayed. No kidding." instead.
In a game where the player could walk around, we would of course want to add a before rule so that he automatically hung up any phone he was using before leaving the room.
The Main Office is a room. The boss is a known woman in the Main Office. A telephone called the red telephone is in the Main Office. Understand "2802" as the red telephone.
The Guild is a room. The ninja is an unknown man in the Guild. A telephone called the black telephone is in the Guild. Understand "4431" as the black telephone.
Potter's Pizza is a room. The pizza delivery boy is a known man in Pizza. A telephone called the saucy telephone is in Pizza. Understand "8885" as the saucy telephone.
The chatter of the boss is the Table of Boss Conversation. The chatter of the delivery boy is the Table of Pizza Conversation. The chatter of the ninja is the Table of Ninja Conversation.
After calling the red telephone on something for the first time:
say "'Yes?' asks the boss. Her voice is especially husky this evening. Maybe that night of passion isn't so far off after all."
topic |
reply |
"love/passion/tonight/night" or "night of passion" |
"'...Sorry, what?' she asks. 'I wasn't listening.' Oh. Maybe she'd go for some pizza, though." |
"pizza" |
"'I'd love some. No pepperoni, though,' she says, sounding dreamy. Yes, this is definitely time for a call to your old friend, the pizza boy." |
"imminent ninja attack" |
"'Don't worry about it,' says the boss crisply. 'I have everything under control.'" |
topic |
reply |
"pizza" |
"'Pepperoni special tonight!' he says proudly." |
"pepperoni" |
"'Pepperoni is included free on ALL our pizzas,' he says proudly." |
"no pepperoni" |
"'Well, I don't see why you'd want that,' replies the boy sniffily. 'It's free!'" |
"jalapeno" |
"'Sorry, we're out of jalapenos this evening. There was a run on them.'" |
"sausage" |
"'Sausage, sure, we can do you sausage.'" |
"canadian bacon" |
"'There's currently an embargo on Canadian pig products.'" |
"cheese" |
"'We use four kinds,' says the boy, then lowers his voice confidentially. 'Actually, two of them are the same. Nobody ever counts. The stringy one, the one that comes in dollops and the orangey one. You know.'" |
"pineapple" |
"'We could put pineapple on there, sure,' says the delivery boy, in a tone that lets you know his opinion of people who order fruit-based pizzas." |
"pineapple and garlic" |
"'What kind of crazy combination is that?' demands the delivery boy, finally losing all self-control." |
"delivery" |
"'Well, I don't know,' says the boy in a worried voice. 'Last time I came there were attack dogs. And ninjas.'" |
"massive gratuity" |
"'There's no use in a big tip you don't live to spend,' says the delivery boy quite firmly." |
topic |
reply |
"imminent attack" |
"'Yes, still on for tonight,' confirms the voice at the other end of the line." |
"pizza delivery boy" |
"The voice, in tones of velvet, indicates that it cannot guarantee the safety of any delivery persons whomsoever." |
Test me with "call 2802 / examine boss / ask boss about night of passion / ask boss about pizza / listen to telephone / call delivery boy on telephone / ask boy about cheese / tell boy about no pepperoni / ask boy about delivery / tell boy about massive gratuity / attack boy".
...and it more or less writes itself from there.
ExampleAlias |
Seven-digit telephone numbers are too long for Inform to handle when compiling to the Z-Machine, but they will work under Glulx. To have this example succeed, make sure that you have selected the Glulx option in your settings menu.
A telephone is a kind of thing. Understand "phone" or "telephone" as a telephone.
A phone number is a kind of value. 999-9999 specifies a phone number.
Now we borrow some techniques from the Understanding chapter to set up dialing actions:
Understand "dial [phone number] on [telephone]" as dialing it on. Understand "dial [phone number] on [something]" as dialing it on.
Understand the commands "phone" or "telephone" or "call" as "dial".
Understand "call [text]" or "phone [text]" or "dial [text]" or "telephone [text]" as a mistake ("That's not a number you know.").
Dialing it on is an action applying to one phone number and one thing.
Report dialing it on:
say "You dial [the phone number understood]."
This much is enough to let us dial telephone numbers and have Inform report that we've done so; it doesn't actually provide a telephone system such that we could reach and converse with other characters (but see the other telephone examples in the recipe book for more on how one might do that).
We'll set up a little political espionage scenario from which our player can make calls:
The Senator's Junior Suite is a room. "The Senator appears, unfortunately, to have very precise habits: little in the room has been moved from its usual place; the trash can is empty; the bed has been remade[if the blue paper is unexamined]. There may in fact be nothing to find here[end if]."
The bed is an enterable scenery supporter in the Junior Suite.
The player is wearing a housekeeping uniform and a brunette wig. The player carries a telephone called a Nokia.
Borrowing again from the chapter on Understanding, we might arrange things so that the player knows and can call a few standard numbers with such syntax as CALL HOME:
And what if we'd like to have the player learn some phone numbers during the game?
A thing can be examined or unexamined. Carry out examining something: now the noun is examined.
Understand "Stephen" as 555-2513 when the blue paper is examined.
This will understand CALL STEPHEN once the paper is examined; before that, the player will just get the "That's not a number you know" response that Inform uses for all attempts to call unknown names.
We'd better plant this paper for the player to find:
The blue paper is in the drawer. The description of the blue paper is "It reads: 'Call Stephen - 555-2513'."
The drawer is part of the dresser. It is closed and openable. The dresser is in The Senator's Junior Suite. The lamp is on the dresser. The description of the dresser is "The single drawer is [if the drawer is open]open[otherwise]shut[end if]."
Test me with "dial 555-9999 / call home on the telephone / phone the president / call stephen / open drawer / read paper / call stephen / put phone in drawer / close drawer / call stephen".