Inform 7 Home Page / Documentation
§12.11. Making actions work for other people
The "photographing" action now works very nicely when the player does it. But not when others try. Suppose that neither the player, nor Clark Gable, is holding the camera:
>photograph clark
You can hardly photograph without a camera, now can you?
An uncanny silence. What has happened is that the rules written so far are all implicitly restricted to the player only. This is because when we write -
Check photographing:
if the camera is not carried:
say "You can hardly photograph without a camera, now can you?" instead.
the action is "photographing", not "Clark photographing". In the next few sections we shall see how to make the rules work nicely for everybody. This is a little bit harder, so it should be noted right away that in many projects there is no need. In a story which has no other characters who succumb to persuasion, for instance, only the player will ever try the action.
Start of Chapter 12: Advanced Actions | |
Back to §12.10. Action variables | |
Onward to §12.12. Check rules for actions by other people |
ExampleThe Man of Steel |
It will sometimes be handy to write actions that are only available to the non-player characters and not to the player. To do this, we just define an action which has no "understand": the player will never be able to specify this command himself, but other characters can try it.
This is particularly useful for creating abstract or general actions for when we want a character to eat something, wear something, or go somewhere, but aren't too particular as to what the object is; as here, where we just want Clark to move away from the kryptonite, regardless of direction:
Carry out someone escaping:
let space be the holder of the person asked;
let place be a random room which is adjacent to the space;
let way be the best route from the space to the place;
try the person asked going way.
Every turn:
if Clark Kent can see kryptonite, try Clark Kent escaping.
Perry White's Office is west of the Newsroom. In Perry White's Office are a desk and a poster of Elvis. On the desk is a lead-lined box. The box is openable. In the box is the green kryptonite crystal.
The Supply Closet is east of the Newsroom. The Elevator Bank is north of the Newsroom.
Clark Kent is a man in the Newsroom. "Clark [if Clark can see the kryptonite]looks a bit ill[otherwise]is here, frowning as he revises his latest article[end if]."
Test me with "west / get box / east / close box / east / west / north / south / west".
ExampleTrying Taking Manhattan |
Inform has built-in commands for other people, and sometimes we may want to adjust the way these work without completely disabling and replacing the command. Suppose, for instance, that instead of
we'd like someone taking inventory to report what he's got, thus:
Kermit the Frog says, "I seem to be carrying a microphone and wearing a hat and a trenchcoat."
To do this, we could replace the built-in report rule with a different one.
The loud inventory rule is listed instead of the report other people taking inventory rule in the report taking inventory rules.
This is the loud inventory rule:
unless the player is the person asked:
say "[The person asked] says, 'I seem to be carrying [a list of things carried by the person asked][if the person asked is wearing something] and wearing [a list of things worn by the person asked][end if].'"
Persuasion rule for asking someone to try doing something: persuasion succeeds.
Grand Central Station is a room. "Here you are in New York, New York. Any minute now someone is going to burst into song."
Kermit the Frog is a man in Grand Central Station. "Kermit the Frog stands nearby, enjoying being green." Kermit is wearing a hat and a trenchcoat. He is carrying a microphone.
ExampleUnder Contract |
The Sound Stage is a room. The description is "A somewhat creaky and unconvincing reproduction of the docks of San Francisco."
Clark Gable is a man in the Sound Stage. "Clark is here, carrying [the list of things carried by Clark][if Clark wears anything] and wearing [the list of things worn by Clark][end if]." Clark carries a swagger stick. Clark carries an open openable player's holdall called a briefcase. The briefcase contains a signed contract. Clark wears a fedora and a pair of pants. A handle is part of the briefcase.
The player carries an open openable player's holdall called a frilly bag. The carrying capacity of the player is 2. The player wears a sparkly scarf and a slinky dress. A strap is part of the bag. The tent is a portable enterable container.
Instead of taking off the slinky dress: say "Rowr! Not that kind of movie, babe."
Instead of taking off the pants: say "That's not your job, whatever the society pages might suggest."
Unsuccessful attempt by Clark doing something:
repeat through table of Clark Retorts:
if the reason the action failed is the cause entry:
say "[response entry][paragraph break]";
rule succeeds;
say "'I don't think that's in the script,' says Clark dubiously."
cause |
response |
can't take yourself rule |
"'I'm always self-possessed,' Clark remarks. You've heard that line before, but it sounds so much more convincing from him." |
can't take other people rule |
"'I don't think it would be appreciated if I tried to do that to [the noun],' he rumbles." |
can't take component parts rule |
"'I don't want to rip [the noun] out,' Clark remarks." |
can't take people's possessions rule |
"'I don't cotton to acting like a thief,' Clark replies. 'It ain't proper.'" |
can't take what you're inside rule |
"'Do you see where I am, babe?' Clark demands." |
can't take what's already taken rule |
"[already done]" |
can't take scenery rule |
"'I'm not the stunt man, darling,' he says with a wry twinkle." |
can't take what's fixed in place rule |
"'I'm not the stunt man, darling,' he says with a wry twinkle." |
can't exceed carrying capacity rule |
"Clark grins. 'I've only got so many hands, darling,' he says." |
can't insert into closed containers rule |
"[physical impossibility]" |
can't go that way rule |
"[physical impossibility]" |
can't go through closed doors rule |
"[physical impossibility]" |
can't enter closed containers rule |
"[physical impossibility]" |
can't exit closed containers rule |
"[physical impossibility]" |
can't drop yourself rule |
"'We're inseparable, me and me,' Clark replies, with a smile." |
can't drop what's already dropped rule |
"[already done]" |
can't drop what's not held rule |
"'Not under my control, [the noun],' replies Clark." |
can't drop clothes being worn rule |
"[salacious retort]" |
can't put something on itself rule |
"'I lack the dexterity,' says Clark. Oh, he's so modest." |
can't put onto what's not a supporter rule |
"'[The second noun] won't support a thing,' says Clark reprovingly." |
can't put clothes being worn rule |
"[salacious retort]" |
can't insert clothes being worn rule |
"[salacious retort]" |
can't give worn items rule |
"[salacious retort]" |
can't wear what's not clothing rule |
"'Costuming just gets stranger every year,' says Clark. 'In short: no.'" |
can't wear what's already worn rule |
"[already done]" |
can't eat unless edible rule |
"'What're you trying to do, poison me?'" |
can't eat clothing without removing it first rule |
"[salacious retort]" |
can't take off what's not worn rule |
"[already done]" |
can't close what's already closed rule |
"[already done]" |
can't open what's already open rule |
"[already done]" |
can't switch off what's already off rule |
"[already done]" |
can't switch on what's already on rule |
"[already done]" |
can't unlock what's already unlocked rule |
"[already done]" |
can't lock what's already locked rule |
"[already done]" |
To say already done:
repeat through Table of Clark's Bored Remarks:
say "[response entry]";
blank out the whole row;
rule succeeds;
say "'Already done.' "
Table of Clark's Bored Remarks
response
"'I have anticipated your every demand.'"
"'We've been through this part of the script already,' Clark remarks, with just a hint of creeping tedium."
"'Right right, already taken care of...'"
"'I'm a believer in rehearsal,' Clark says, sounding more bored than ever, 'but we really have got all this done already.'"
To say salacious retort:
repeat through Table of Clark's Flirtatious Remarks:
say "[response entry]";
blank out the whole row;
rule succeeds;
say "Clark, driven past the point of endurance, seizes you in his arms and kisses you.";
end the story finally.
Table of Clark's Flirtatious Remarks
response
"Clark allows his mustache to quirk at the suggestion."
"Clark wiggles his eyebrows at you."
"'That kind of thing isn't in my contract, sweetie,' says Clark. 'If you're interested you'll have to ask off-camera.'"
"'I'd feel so... bare,' Clark says, with a sidelong look at you."
"'You first,' says Clark."
"Clark's stare is intense. You may be on the verge of breaking him."
To say physical impossibility:
repeat through Table of Clark's Frustrated Denials:
say "[response entry]";
blank out the whole row;
rule succeeds;
say "Clark makes a helpless gesture about his ability to move himself, or parts of himself, through solid objects. "
Table of Clark's Frustrated Denials
response
"Clark frowns. 'I can't reach through things -- unless you were planning a special effect?'"
"'Look,' says Clark. 'If you want a stage magician, hire one.'"
"Clark just groans."
"Clark says drily, 'Is this in the script, or are we doing improvisation now?'"
The block giving rule is not listed in the check giving it to rules. The block showing rule is not listed in the check showing it to rules. The report smelling rule is not listed in the report smelling rules. The report listening rule is not listed in the report listening to rules.
Report listening to something: say "Your attention bears no interesting result."
Report smelling something: say "Your attention bears no interesting result."
Report someone listening to something: say "[The person asked] concentrates, listening."
Report someone smelling something: say "[The person asked] sniffs at [the noun]."
Instead of asking someone for something: try asking the noun to try giving the second noun to the player.
Carry out showing something to someone: say "You reveal [the noun] to [the second noun]."
Carry out Clark showing something to someone:
if the second noun is the player:
say "Clark shows you [the noun]. [run paragraph on]";
try examining the noun;
otherwise:
say "Clark reveals [the noun] to [the second noun]."
Instead of asking someone to try saying yes: try saying yes. Instead of asking someone to try saying no: try saying no. Instead of asking someone to try saying sorry, try saying sorry.
And now we make Clark a very amenable type:
A persuasion rule for asking people to try doing something: persuasion succeeds.
There are quite a few actions for which no automatic other-character behavior is provided at all, because they always end in failure when the player tries them. Currently the response is not very interesting. Let's spice it up a bit:
Burning something is useless action. Waking up is useless action. Thinking is useless action. Cutting is useless action. Jumping is useless action. Tying something to something is useless action. Drinking something is useless action. Swinging is useless action. Rubbing is useless action. Setting something to something is useless action. Waving hands is useless action. Buying is useless action. Climbing is useless action. Sleeping is useless action. Kissing is useless action. Throwing something at something is useless action. Attacking is useless action. Asking something about something is useless action. Telling something about something is useless action. Answering something that something is useless action. Waking something is useless action.
A persuasion rule for asking people to try useless action:
say "Clark Gable frowns. 'I don't mean to be difficult, but I can't see any point in that.'";
persuasion fails.
A persuasion rule for asking Clark to try taking off the pants:
say "He gives you a look of mocking exasperation. Apparently you'll have to take a (slightly) more subtle approach.";
persuasion fails.
Check someone giving something to someone (this is the can't give worn items rule):
if the person asked wears the noun, stop the action.
And because we do not want Clark automatically taking off the pants as the result of a drop action:
We know that this can only come about as a default action, because we have arranged matters so that he cannot be persuaded directly.
Test me with "give dress to clark / clark, take off pants / clark, eat pants / clark, give me the pants / clark, drop pants / clark, put the pants in the briefcase / again / g / g / g"