Let's Play/Read: Inform 7 manuals (Done for now)

Chapter 12: Advanced Actions, Part 1:

This is, I think, the second longest chapter left in the book, so I might only do part of it today.

I believe most of this chapter is about defining new actions and about Check, Carry out, and Report, but we’ll see.

12.1 is A recap of actions.

This just mentions the ACTIONS testing command, the fact that actions can succeed or fail, and that we can initiate actions through the ‘try’ phrase or players can initiate them by typing.

Before rules, intended so that preliminary activities like the one above can happen before the action is tried; Instead rules, which block or divert the intention, or may cause something spectacularly different to happen; and After rules, which allow for unexpected consequences after the action has taken place.

Section 12.2 is How Actions are processed, which contains the following helpful image:

The orange boxes for Before, Instead and After were covered in the Basic Actions chapter, but the blue boxes are new. The orange boxes are where we put rules to handle unusual situations, or unexpected events[…]Blue boxes hold the mundane, everyday rules - the generic ways that particular actions behave. Every action provides these: “Check” rules, to see if it makes sense - for instance, to see that the player is not trying to take his or her own body, or a whole room, or something he or she already has; then “Carry out” rules, to actually do what the action is supposed to do - in the case of taking, to move an object into the player’s possession; and finally “Report” rules, which tell the player what has happened - perhaps printing up “Taken.”

I always saw the difference as ‘Check/Carry out/Report’ are for defining your own actions and ‘Before/Instead/After’ are for messing with pre-existing actions.

Section 12.3 is Giving Instructions to other people.

Inform has a lot of code for doing this, but the only places I can remember seeing this off the top of my head are the mouse robot in Curses and the whole game of Ollie Ollie Oxen Free by Caroline Van Eseltine (I know it exists elsewhere, these are just the first and only ones I thought of).

It says that the difference between go west and will, go west is that they are respectively interpreted as:
going west and
asking Will to try going west

To write rules about this, do as so:
Instead of asking Will to try going west, say "Will scratches his head, baffled by this talk of westward. Is not the ocean without bound?"

The default person getting asked is ‘the person asked’, making this different than most verbs.

Instead of asking somebody to try taking something, say "I don't think we ought to tempt [the person asked] into theft, surely?"

Example 184 is Virtue:

Attacking someone is misbehavior. Kissing someone is misbehavior.

Instead of asking someone to try misbehavior: say "[The person asked] stiffens, offended by your suggestion."

Example 185 is Latris Theon:

Hermes is a man in Corinth. The destination of Hermes is Corinth. [So he is initially happy where he is.] Persuasion rule for asking Hermes to try going vaguely: persuasion succeeds. [But he is open to suggestions.]

A person has a room called destination.

Every turn when the destination of Hermes is not the location of Hermes:
    let the right direction be the best route from the location of Hermes to the destination of Hermes;
    try Hermes going the right direction.

Section 12.4 is Persuasion, something I never understood (which is likely why I never coded in asking people to try actions).

By default, people won’t do what you want:

> will, go west
Will has better things to do.

However, we can intervene to make the

But you can change that for individual requests by creating a ‘persuasion rule’:

Persuasion rule for asking people to try going: persuasion succeeds.
Persuasion rule for asking Will to try going west: persuasion succeeds.

You can say ‘persuasion succeeds’, ‘persuasion fails’, or neither. Either way, you can say something:

Persuasion rule for asking Will to try going:
    say "Will looks put out, and mutters under his breath.";
    persuasion fails.

This replaces the “Will has better things to do” message.

Persuasion rule for asking people to try doing something: persuasion succeeds. lets you persuade everybody to everything all the time. From personal experience, many actions that others attempt to not produce a message, so you may think this isn’t working, but it is (while I don’t do persuasion, I have had NPCs copying the player).

If will, go west succeeds in persuasion, then an action happens internally called Will going west. You can say:

Instead of Will going west, say "He runs out into the waves, but soon returns, rueful.".

I have rules like this for my clone:

Cloneheadedout is a truth state that varies. Cloneheadedout is false.

Before clone-you going:
	if clone-you is enclosed by the location:
		now cloneheadedout is true;

After clone-you going:
	if clone-you is in the location of the player:
		say "The clone[setcloneact] arrives, following your movements.";
	otherwise if cloneheadedout is true:
		say "Your clone heads out to [the noun]."

Instead rules, when used in persuasion, count as failures and print failure messages. So:

Instead of Will pulling the cord:
    say "The bell rings."

produces:

>WILL, PULL CORD
The bell rings.

Will is unable to do that.

Example186 is The Hypnotist of Blois:

A person is either hypnotized or alert. A person is usually alert.

Persuasion rule for asking a hypnotized person to try doing something:
persuasion succeeds.

Understand "hypnotize [someone]" as hypnotizing.

Hypnotizing is an action applying to one thing.

Check hypnotizing:
if the noun is hypnotized, say "Already done." instead.

Carry out hypnotizing:
now the noun is hypnotized.

Report hypnotizing:
say "[The noun] slips under your control."

This is a classical example of the before, carry out, report dialog.

Although it says this command keeps other people from hypnotizing you:

Check someone hypnotizing someone:
    stop the action.

What I don’t get is, why doesn’t that prevent you from hypnotizing others?

Example 187 is Police State:

Persuasion rule for asking the policeman to try doing something: persuasion fails.

Persuasion rule for asking someone to try doing something: persuasion succeeds.

The policeman is a man in Seventh Avenue. "A policeman with a very guarded expression is watching you."

Smelling a person is disorderly conduct. Tasting a person is disorderly conduct. Jumping is disorderly conduct. Singing is disorderly conduct.

Instead of someone trying disorderly conduct in the presence of the policeman:
    say "The policeman arrests [the person asked]!";
    now the person asked is nowhere;
    the rule succeeds.

‘Rule succeeds’ here keeps Inform from counting it as a failure and printing failure messages.

Section 12.5 is Unsuccessful attempts.

This introduces some interesting notation I’ve never seen. Basically, if an action succeeds in persuasion but fails due to some check rule or something (like trying to go through a wall), inform usually prints out Will [or whoever] is unable to do that.

You replace that as so:

Unsuccessful attempt by Will going: say “Will blunders around going nowhere, as usual.”

But this prints for every failed attempt, whether it’s because doors are locked or whatever, so you can instead type:

Unsuccessful attempt by Will going:
    if the reason the action failed is the can't go through closed doors rule, say "Will looks doubtful and mumbles about doors.";
    otherwise say "Will blunders around going nowhere, as usual."

This would have been helpful to know last year, when I spent weeks typing stuff like this:

Instead of clone-you examining something:
	if clone-you is enclosed by the location:
		if the noun is something which can be seen by clone-you:
			say "Your clone[setcloneact] looks closely at [the noun].";
		otherwise:
			say "Your clone[setcloneact] tries to look at [the noun] but doesn't see it anywhere.";

I’m not going to change it now, because it works, but man, this is wild stuff.

To know the ‘reason an action failed’, you can type ACTIONS it will tell you what rule is at fault.

Oh, it looks like ‘unsuccessful attempt’ is only used for persuasion; since all of my clone’s actions are caused by ‘try’ phrases, this would have done nothing anyway. Good to know!

We should have a ‘persuasion’ theme for one of the next big comps so people can try this stuff out, because I just rarely see it in use.

Example 188 is Generation X, a pretty funny example:

Unsuccessful attempt by Jenna doing something:
repeat through Table of Retorts:
if the reason the action failed is the cause entry:
say “[response entry][paragraph break]”;
rule succeeds;
say “‘I don’t see how I’m supposed to do that, Mom,’ Jenna says.”

Table of Retorts

cause response
can’t take yourself rule “‘Is that like ‘get a grip on yourself’ or something?’ Jenna asks, momentarily diverted.”
can’t take what’s fixed in place rule “[physical impossibility]”
can’t take scenery rule “[physical impossibility]”
can’t take what’s already taken rule “[already done]”
can’t drop what’s already dropped rule “[already done]”
can’t wear what’s already worn rule “[already done]”
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

To say physical impossibility:
say "‘Maybe you should’ve brought someone a little stronger,’ Jenna says. ‘Like the Incredible Hulk.’ "

To say already done:
repeat through Table of Bored Remarks:
say “[response entry]”;
blank out the whole row;
rule succeeds;
say "‘Okay, I’m going to be, like, in the car,’ says Jenna. ‘Outside.’ ";
end the story saying “Jenna has gotten fed up”.

Table of Bored Remarks
response
“‘Did that,’ says Jenna.”
“‘Check,’ says Jenna.”
“‘Yeah, Mom, I already did that, okay?’”
“‘Look, if I have to be here doing dumb stuff, could you at least tell me to do stuff that isn’t already done?’ Jenna asks wearily.”
“Jenna gives a great upward sigh, riffling her bangs. ‘Once again… there is totally no point.’”

Section 12.6 is Spontaneous actions by other people

This is what I was talking about earlier: using ‘try’ phrases. Like this;
try Will going west.

If we tell it to try ‘silently’, it skips the ‘report rules’.

To repeat a point in the previous section: “unsuccessful attempt” rules do not apply to actions which the author has caused to happen, using “try”. When such actions fail, they invoke no special set of rules. Indeed, when “try” causes somebody other than the player to try an action, nothing will be printed to report back on success or failure.

If you have a complex person name and Inform isn’t parsing it, you can add trying after the name ends. So for a guy named Will Going:
try Will Going trying going west

Example 189 is IQ Test:

A persuasion rule for asking someone to try doing something:
    persuasion succeeds.

Before someone opening a locked thing (called the sealed chest):
    if the person asked is carrying the matching key of the sealed chest, try the person asked unlocking the sealed chest with the matching key of the sealed chest;
    if the sealed chest is locked, stop the action.

Before someone taking something which is in a closed container (called the shut chest):
    try the person asked opening the shut chest;
    if the shut chest is closed, stop the action.

The block giving rule is not listed in the check giving it to rules.

This is basically making implicit actions for people besides the player.

Example 190 is a rare 4-star example called Boston Cream, which is like the above example but fully developed.

It includes reactions like this:

Before someone opening a locked thing (called the sealed chest):
    if the person asked can see the matching key of the sealed chest:
        if the matching key of the sealed chest is enclosed by the sealed chest:
            say "Seeing the paradoxical location of [the matching key of the sealed chest], [the person asked] gives a howl of rage.";
            increment the score;
            end the story finally saying "You have thwarted Ogg";
        otherwise:
            try the person asked unlocking the sealed chest with the matching key of the sealed chest;
        stop the action.

and independent actions like this:

Every turn:
    increment the hunger of Ogg;
    if the hunger of Ogg is 2 and Ogg is visible, say "Ogg's stomach growls.";
    if the hunger of Ogg is 3 and Ogg is visible:
        if Ogg can see an edible thing (called the target):
            say "Ogg eyes [the target] with obvious intent.";
        otherwise:
            say "Ogg glances at you in a disturbingly shifty way.";
    if the hunger of Ogg is greater than 3:
        if Ogg carries an edible thing (called the target):
            try Ogg eating the target;
        otherwise:
            let new target be a random edible thing which can be seen by Ogg;
            if the new target is a thing:
                try Ogg taking the new target;
            otherwise:
                if Ogg can touch the player, end the story saying "Ogg is gnawing your ankle";
                otherwise try Ogg taking the player.

Section 12.7 is New actions.
At the top, it says

It is not often that we need to create new actions, but a large work of interactive fiction with no novelty actions is a flavourless dish.

I feel like that’s both true and not true. Very new players will often not create any new actions; somewhat experience players will often force definitions of new actions and use the ‘understand ___ as something new’ a lot; experience authors can often redirect old actions to do what they want, although some new actions are always good.

Examples of actions many games can use is ABOUT, CREDITS, HELP, and TALK TO, while a lot of games have XYZZY as an action. SING is often implemented, and there’s a running joke between a couple of people on this board about LICK being a useful action.

Here’s their example for defining an action:

The Ruins is a room. "You find this clearing in the rainforest oddly familiar." The camera is in the Ruins. "Your elephantine camera hangs from a convenient branch."

Photographing is an action applying to one visible thing and requiring light.

You know, this might be where all the ‘visible’ confusion comes from:

Summary

because the very first example of defining a function includes the word visible while most commands the player creates will not need to use that word.

Visible means that the action applies to directions and to things in transparent containers, among others. Touchable is the default for things; you don’t have to mention that an action applies to a touchable thing as it’s assumed.

You can create if statements based on the touchability requirements of something:

if action requires a touchable noun:
if action requires a touchable second noun:
if action requires a carried noun:
if action requires a carried second noun:
if action requires light:

This might radically change how I handle distant or immaterial objects in my games. I current just have a kind of actions called ‘physicality’ and manually list things like touching, pulling, and pushing, and then have ‘instead of physicality when the noun is ___’ rules.

Instead, it looks like I could just do

Before doing something to a distant thing:
  if the current action requires a touchable noun:
   say "[The noun] [are] too far away!;

I haven’t tested this, but I may try it out in the future.

Action names typically don’t have the nouns in them. This is awkward if it has two nouns, so you put it where the first noun goes:

Blinking is an action applying to nothing. Scraping it with is an action applying to two things.

Actions are impossible for the player to use unless you add a way for them to use them, so we have phrases like this:
Understand "photograph [something]" as photographing.

Notice we just call it photographing, with no nouns, on the right side.

Example 191 is Red Cross, which is our first example and which again uses ‘visible’:

Diagnosing is an action applying to one visible thing. Understand "diagnose [something]" as diagnosing.

Check diagnosing:
if the noun is not a person, say "Only people can have diagnoses." instead.

Carry out diagnosing:
say "You're not a medical expert."

Instead of diagnosing the player:
say "You feel fine!"

Example 192 is a very complex example called Frizz about adding a whole new set of rules to pre-existing commands:

A liquid distribution rule:
    repeat with item running through containers:
        if the item is open and the item is empty and the item is in a waterfilled container:
            now the item is waterfilled;
            if the player can see the item, say "[The item] fills up with water, of course.".

A liquid distribution rule:
    repeat with item running through things in a waterfilled container:
        if the item is porous and the item is dry:
            if the player can see the item, say "[The item] soaks through.";
            now the item is sodden.

A liquid distribution rule:
    repeat with item running through sodden things in the airing cupboard:
        if the item is not The Last Man, now the item is dry.

The last liquid distribution rule:
    if the player carries a dry copy of The Last Man, end the story finally.
The post-check rules are a rulebook.

This is the post-check stage rule:
    abide by the post-check rules.

The post-check stage rule is listed before the carry out stage rule in the specific action-processing rules.

A post-check rule (this is the dry glove rule):
    if we get wet:
        if the player wears the gloves and the gloves are dry:
            now the gloves are sodden;
            say "(soaking your gloves in the process)";
    continue the action.

A post-check rule (this is the wet glove rule):
    if the player wears the sodden gloves:
        if the The Last Man must be touched and the Last Man is not sodden:
            say "(soaking the parched pages of The Last Man with the rude touch of your sodden gloves)";
            now the The Last Man is sodden;
        continue the action.

This is only part of this very complex example. And we still haven’t seen any ways of defining actions without requiring a visible thing.

Example 193 is 3 AM:

Understand "shake [something preferably held]" as shaking.

Shaking is an action applying to one carried thing.

Carry out shaking:
say "Nothing results of your shaking [the noun]."

Instead of shaking a closed container when something is in the noun:
say "Something rattles inside [the noun]."

Instead of shaking a closed transparent container when something is in the noun:
say "Inside [the noun] there are banging noises produced by [the list of things contained by the noun]."

Instead of shaking an open container which contains something:
say "[The list of things contained by the noun] might fly out."

Hmm, I haven’t used ‘one carried thing’ in definitions before, I’m going to go fix that (I have a bunch of instead rules instead).

So every example in this chapter puts an adjective in the ‘applying to’ clause.

SEction 12.8 is irregular english verbs, and just explains why Inform doesn’t guess what the Understand phrase should be:
Understand "scrape [something] with [something]" as scraping it with.

English is so full of irregular verbs. Inform could have guessed “blink” and “photograph”, but might then have opted for “scrap” instead of “scrape”.

Inform does make past participles automatically, but if it gets it wrong, you can guess:
Squicking is an action with past participle squacked, applying to one thing.

And there we go, our first example without an adjective in the action definition.

Section 12.9 is Check, Carry out, report. This is a pretty important section!

It gives a nice and tidy example of how the rules go:

Check photographing. Here, for instance, we need to verify that the player has the camera. If any of our checks fail, we should say why and stop the action. If they succeed, we say nothing.

Carry out photographing. At this stage no further checking is needed (or allowed): the action now definitively takes place. At this point we might, for instance, deduct one from the number of exposures left on the film in the camera, or award the player points for capturing something interesting for posterity. But we should say nothing.

Report photographing. At this stage no further activity is needed (or allowed): whatever effect the action had, it has happened and is now over. All we can do is to say what has taken place.

So if you want your brand new action to require certain things, throw it in a check rule:

A check photographing rule:
    if the camera is not carried:
        say "You can hardly photograph without a camera, now can you?" instead.

or, as is more common,

Check photographing:
    if we have photographed the noun:
        say "You've already snapped [the noun]." instead.

The standard messages go in ‘report’:
Report photographing: say "Click!"

You can go on to add special cases that testers find out:

Check photographing:
    if the noun is the camera:
        say "That would require some sort of contraption with mirrors." instead.

Lots of examples!
Example 194 is The Dark Ages Revisited:

This example shows that you can add on to preexisting behavior without overwriting it using Carry On:
An electric light is a kind of device. Carry out switching on an electric light: now the noun is lit. Carry out switching off an electric light: now the noun is unlit.

It also has some nice stuff about avoiding unnecessary messages when examining things like devices or containers.

Example 195 is Paddington:
This extends a pre-existing verb (CUT) to a more complex verb (CUT ____ WITH ____). This is a great example since it comes up alot.

In this code, just ‘cutting’ by itself is the old, preexisting action, and ‘cutting it with’ is our new action:

Understand "cut [something] with [something]" as cutting it with.

Instead of cutting something:
    if a blade (called the edge) is held by the player,
        try cutting the noun with the edge;
    otherwise say "Your fingernails are not sharp enough."

Cutting it with is an action applying to two things.

Check cutting it with:
    if the noun is a person, say "That would hurt." instead;
    if the second noun is not a blade, say "[The second noun] has not got enough of a blade." instead.

Carry out cutting it with:
    increment the count of rips of the noun.

Report cutting it with:
    say "You slash [the noun] with [the second noun]."

It then adds lots of nice little rules to document your reign of terror.

Example 196 is Delicious, Delicious Rocks:
This example stops implicit actions that are clearly going to lead to dumb results.

The sanity-check rules are a rulebook.

This is the sanity-check stage rule:
abide by the sanity-check rules.

The sanity-check stage rule is listed after the before stage rule in the action-processing rules.

Sanity-check eating an inedible thing:
    say "Your digestion is so delicate -- you're sure [the noun] wouldn't agree with you." instead.

This keeps you from picking up a rock before eating it.

It then mentions the pros and cons between this method and just doing a ‘before…instead’ rule.

Example 197 is Noisemaking:
This adds a new rulebook for people reacting to actions.

The other-player response rule is listed after the report stage rule in the specific action-processing rules.

This is the other-player response rule:
follow the observation rules.

The observation rules is a rulebook.

Singing is a loud action.

Attacking the drum is a loud action.

The block attacking rule is not listed in any rulebook.

Report attacking something:
    say "THWACK!"

An observation rule for loud action in the presence of the black crow:
    let N be a random adjacent room;
    if N is a room, move the black crow to N;
    say "The crow, startled, flies off to [N]."
1 Like