Chapter 7: Actions
Now we finally get to do stuff!
I usually associate ‘actions’ with commands the player types, but they don’t have to be synonymous.
We write actions using present participles. For instance, if the player types “take napkin” or “get the napkin” or something similar then the resulting action would be written as:
taking the napkin
Every action ends in success or failure. In this context, success means only that the player’s intention has been fulfilled. If the player sets out to take the napkin, but finds a million-pound banknote in its folds instead, the action will be deemed to be a failure.
There’s a testing command called ‘ACTIONS’ that prints out what actions are happening. I used this a lot in my game when debugging a clone that copies the players actions exactly two turns after you start them.
Here’s what the output looks like:
>s
[going south]
Security Vault
You can see a metal door here.
[going south - succeeded]
>close door
[closing metal door]
You close the metal door.
[closing metal door - succeeded]
>take door
[taking metal door]
That's fixed in place.
[taking metal door - failed the can't take what's fixed in place rule]
(This is from the text; I swear there should be an implicit looking action when they go south because when I was doing the clone thing there was an implicit look action).
Hmm, actually I just tried it in a sandbox and the Actions command doesn’t pick up on the implicit LOOK.
Section 7.1 is Instead rules. This is kind of the bread and butter of Inform programming; it’s what people usually start with, and many experienced programmers use it a lot, too.
An action is ordinarily handled by running it through Inform’s extensive rulebooks of what might be called normal behaviour. An action such as “taking the napkin”, for instance, will be run through numerous checks to see if it is physically reasonable, and then provided all is well, the napkin will be moved into the possession of the player.
Instead, though, we can bypass the rules to do with an action and do something else:
Instead of eating the napkin: say "Why not wait for the actual dinner to arrive?"
This is a rule (one of our first ones), called an ‘instead rule’.
You can also do it in one line:
Instead of eating the napkin, say “Why not wait for the actual dinner to arrive?”
Some examples:
Example 84, Grilling
Instead of taking something which is on the grill:
say "'Hey, you'll burn yourself,' says Mom."
This example uses the ‘descriptions’ from last chapter, with the ‘which is on the grill’ part.
Example 85: Bad Hair Day replaces the player’s description:
Instead of examining the player:
say "Oh, stop fussing. You look fine."
This is different from the description of the player, since, if unspecified, the player is an amorphous blob person called ‘yourself/your former self’ and the description of the player is attached to that being; changing to a different person (with the command ‘now the player is ____’) changes the description.
But this method gives the same description no matter who you are. This comes up a lot for me in my games because I often switch who the player is (in flashbacks in Color the Truth, for instance, or when controlling a giant death robot in Absence of Law).
Section 7.3 is Before Rules
These are like instead rules, but they happen before you do something. When I had my clone copying the player, I first was using Instead/carry out rules and the clone couldn’t copy unsuccessful attempts at things. Then I switched to ‘before’ rules and that let the clone attempt unsuccessful things/actions with inappropriate objects (like eating rocks).
Anyway, here’s what the section says:
“Before” rules genuinely precede checking of any kind. They also differ from instead rules in that they do not automatically stop the action in its tracks. Rather, they are provided as an opportunity to ensure that something else is done first. For example:
Before taking the napkin, say "(first unfolding its delicate origami swan)".
whence
>GET NAPKIN
(first unfolding its delicate origami swan)
Taken.
Often you still want to stop the normal actions, so you can just throw an ‘instead’ into the before rule. I always put it at the very end of a block like this:
Before going north:
do thing1;
do thing2;
do thing3 instead;
But apparently it can go in front too:
Before taking the key, instead say "It seems to be soldered to the keyhole."
There is also a line called ‘stop the action’, which I’ve tried before and never does what I want. I tried to use it to stop the implicit LOOK action after going, but it doesn’t do that, it seems.
stop the action
This phrase stops the current rule, stops the rulebook being worked through, and finally stops the action being processed. Example:
Before taking the key:
say "It seems to be soldered to the keyhole.";
stop the action.
We can also stop it from stopping:
Instead of taking the napkin:
say "(first unfolding its delicate origami swan)[command clarification break]";
continue the action.
Hmm…I never got this before! ‘stop the action’ turns a before rule into an instead rule with slightly more power (due to firing before all other instead rules), while ‘continue the action’ turns an instead rule into a slightly weaker before rule.
Weird!
As a general principle, it is good style to use instead rules whenever blocking actions, and before rules only when it is genuinely necessary to do something first but then to continue: in fact, it is good style to use “stop the action” or “continue the action” as little as possible.
Example 86 is Democratic Process shows a useful before rule:
Before inserting something which is not carried by the player into something:
if the noun is in the second noun, say "Already done." instead;
say "(first taking [the noun])[line break]";
silently try taking the noun;
if the player is not holding the noun, stop the action.
In my mind, from now on I’ll think ‘stop the action is just like ‘instead’ except you put it in as its own command instead of at the end of another command’
Example 87 is Sand, a rare 4-star example. It allows you to put multiple things in other things. It includes the text of 86 as well as this line:
Understand "put [things] in [something]" as inserting it into. Understand "put [things] on [something]" as putting it on.
Section 7.4 is Try and Try silently.
[S]urveys of Inform source text showed that the three most popular phrases used by authors are “say”, “if” and “now”. The fourth most popular is “try”…
‘Try’ is what lets the computer do an action itself rather than waiting for the player to type it in.
Instead of entering the trapdoor, try going up.
This is one of the basic phrases players need to learn. In fact, so far I’d recommend new players start reading this chapter before any of the others!
You have to be specific in your action, and can’t type:
try eating something;
We use ‘try’ because it might fail:
Before locking the front door, try closing the front door.
could go wrong in any number of ways - perhaps the door is closed already, perhaps it is not openable, perhaps somebody has wedged it open. It would be safer to write:
Before locking the front door:
try closing the front door;
if the front door is open, stop the action.
You can also do ‘silently’ which means that routine messages aren’t printed (I assume this means the ‘carry out’ messages’):
`try silently taking the napkin;`
Silence is maintained only if this new action, the taking of the napkin, is successful (so if the napkin is successfully taken, the text “Taken.” will not appear): if the action should fail, a suitable objection will be voiced as usual.
Example 88, Fine Laid, is a way of redirecting one object to another in all situations except examining:
The sheet of paper is a thing in High Street Stationer. The writing is part of the sheet of paper.
The description of the sheet of paper is "A beautiful sheet of heavy cream paper." The description of the writing is "Delicate and spidery."
Instead of tasting the sheet of paper, say "You might need more fiber in your diet, but this isn't the way.".
Before doing something other than examining when the current action involves the writing:
if the writing is the noun, now the noun is the sheet of paper;
if the writing is the second noun, now the second noun is the sheet of paper;
try the current action instead.
This is our introduction to ‘the current action’ as an object, as well.
My current game has tons of ‘labelled’ items or things with inscriptions. This might be a nice way of handling that…
Example 89 is ‘Hayseed’:
A staircase is a kind of door. A staircase is usually open. A staircase is seldom openable.
The ladder is a staircase. It is above the Barn and below the Hayloft.
Instead of climbing a staircase:
try entering the noun.
I think I have this almost word for word in my current game.
Finally, we have 7.5, After rules, which completes the three main ways we mess around with rules: Before, Instead, and After. Later on, we’ll see Check, Carry Out, and Report, which are very similar but used more when defining new actions.
After rules replace Inform’s normal responses:
After taking the diamonds, say "Taken!"
just says ‘Taken!’ instead of
'Taken.
Taken!’
which is what you’d get if the normal response fired off.
You can also ‘continue the action’:
After taking the diamonds: say "(Mr Beebe looks up sharply.) "; continue the action.
If I understand this right (correct me if not) this is almost identical to using ‘instead’ with ‘continue the action’ here, except that with ‘instead’ the above line would be printed before the game actually took the object and with ‘after’ it’s printed after it took the object, which would matter if you change what’s printed based on the location of the object.
The only example is Example 90, Morning After:
A thing can be examined or unexamined.
After taking something unexamined:
say "Taken. [run paragraph on]";
try examining the noun.
Carry out examining something:
now the noun is examined.
I have a flag in my game called ‘oncetaken’, which I think is identical to Inform’s ‘handled’, which I didn’t know existed at the time.
Section 7.6 is “Reading and Talking”. This feels more like a ‘Recipe Book’ section than a ‘Writing with Inform’ section.
For players to type ‘look up ___ in ___’ or "consult __ about ___’ we use the consulting it about action:
After consulting the book about "grove", say "The Grove is a sacred yadda, yadda. There's a tree, that sort of thing. Wisdom."
After consulting the book about "future events", say "It's a bit, what's the word? Delphic."
Here “grove” and “future events” are ‘texts’ (i.e. strings) and not objects.
Here’s the examples for asking about:
After asking the Sybil about "verses", say "She blushes."
After telling the Sybil about "persians", say "She nods gravely."
After answering the Sybil that "I am mad", say "She sighs."
Man, again I’d have to say that this is the first chapter I’d send a newbie to.
You can redirect ‘telling’ to ‘asking’ like so:
Instead of telling the Sybil about something, try asking the Sybil about it.
I have a custom conversation engine and I redirect ‘talking to’, ‘answering it that’, ‘asking it about’, ‘telling it about’, etc. to error messages detailing how to use my system.
There are lots of examples here; you can tell both authors are enthusiastic about this.
Example 91 is Sybil 1:
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."
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."
I also redirect giving and showing since it’s rare you want different activity for these two in my games.
This example also includes some phrases using the slash format Mike Russo expressed fondness for:
Instead of asking the Sybil about "Darius/king", say "Her smile unnerves you."
Example 92 redirects one conversational topic to another:
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."
Example 93 is Sybil 2, who can also understand various forms of saying ‘yes’: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.
Example 94 is 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.
The Guide to Central American Birds is a book carried by the player. The contents of the Guide is the Table of Listed Birds.
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.” |
(note that Discourse is weird copying and pasting tables so I did it this way).
Section 7.7 is The Other Four Senses (Again, very happy this section is so grounded in reality)
I’m just going to reproduce this section in full:
The five senses are all simulated with actions. Sight is so informative that it is handled by a whole range of actions: “looking”, which describes the general scene; “examining something”, which takes a closer look at a specific thing; “looking under something”, and so on.
The other senses have one action each: “listening to something”, “touching something”, “tasting something” and “smelling something”. It makes no sense to touch or taste the general scene, but listening and smelling are a different matter: we often just listen, without listening to anything specific. If the player types the command “listen”, Inform understands that as listening to the current location: similarly for the bare command “smell”. Thus:
Instead of listening to the Seashore, say "The song of gulls."
Instead of smelling the Cave, say "Salt and old seaweed."
This was useful for me in my current game where there is a dark room but you have to find two different objects, one by smelling and another by listening.
Example 95 is The Art of Noise, which is about listening and smelling:
A thing has some text called sound. The sound of a thing is usually "silence".
The report listening rule is not listed in the report listening to rules.
Carry out listening to something:
say "From [the noun] you hear [the sound of the noun]."
Instead of listening to a room:
if an audible thing can be touched by the player, say "You hear [the list of audible things which can be touched by the player].";
otherwise say "Nothing of note."
Definition: a thing is audible if the sound of it is not "silence".
Before printing the name of something audible while listening to a room:
say "[sound] from the "Preformatted text
This example shows unlisting a rule:
‘The report listening rule is not listed in the report listening rules’.
I usually just say ‘The report listening rule does nothing when …’. Not sure what the advantages are between doing nothing and unlisting.
Section 7.8 is Rules applying to more than one action.
You can say:
Instead of examining, looking under or searching the desk: say "There's no use poking around in that old desk."
I don’t know if this is still true, but at one point I had a rule like that with a ton of actions in it but it really slowed down compiling. Instead I used a different construction, like:
Examining is investigation.
Looking under is investigation.
Searching is investigation.
Instead of investigation when the noun is the desk:
say "blah blah blah"
Section 7.9 is All actions and exceptional actions.
You can just type ‘doing something’ or ‘doing anything’ if you want to catch all possible interactions.
I do this with objects the player saw but aren’t there anymore. So if a monkey ran by and disappears, I make a scenery object called ‘missing-monkey’ or something and say
Instead of doing anything when the noun is the missing-monkey:
say "The monkey is already gone!"
Although I notice that I said ‘when the noun is’ and they said ‘to the…’, which seems more general, since the monkey could be the second noun.
Oh, wait, maybe it’s not more general:
“Putting the handbag on the cucumber sandwich” would also not qualify as “doing something to the cucumber sandwich” - only to the handbag.
You can also add exceptions:
Instead of doing something other than examining, taking or dropping with the dagger: say "Don't fool around with that dagger. It's exceedingly sharp."
Note the “with”, which is crucial here. Without it, the rule is subtly different:
Instead of doing something other than examining, taking or dropping the dagger: say "Don't fool around with that dagger. It's exceedingly sharp."
This second version matches if the action is, say, taking a shield, or even just looking, because that would be an action other than examining the dagger, taking the dagger or dropping the dagger.
Example 96 is Zodiac:
Instead of doing something other than looking or examining in the presence of the Capricorn Killer:
say "You dare not attempt it!"
This example also introduces ‘in the presence of’ (unless maybe that was covered in the ‘visible’ section before?)
Section 7.10 is The noun and the second noun (not, as I learned through cruel experience, The first noun and the second noun).
Basically, if you want to refer to the object of an action , call it ‘the noun’:
Instead of examining something, say "[The noun] is none of your concern!"
This is a pretty vital thing to know how to use!
‘The second noun’ is used for actions that apply to two things, and means the second thing you typed (unless you set up actions ‘with nouns reverse’, in which case its the first thing you typed).
Despite ‘the second noun’ being in the section name, there are no examples in the text or in th examples section that use it. So schade
Example 97 is Ming Vase:
A thing can be strong or fragile. A thing is usually strong.
Instead of attacking or dropping a fragile thing:
now the noun is nowhere;
say "[The noun] breaks into thousands of pieces!"
The pillow is a portable supporter. It is carried by the player.
Instead of dropping a fragile thing when the pillow is in the location: try putting the noun on the pillow instead.
After putting a fragile thing on the pillow:
say "You set [the noun] down gently on the pillow."
Example 7.11 is In rooms and regions.
You can just add conditions on actions only in certain areas:
Instead of taking something in the Supernatural Void, say "In this peculiar mist you feel unable to grasp anything."
You can also do this in regions:
The Public Area is a region. The Arboretum and Gardens are in the Public Area.
Instead of eating in the Public Area, say "The curators of the Gardens are ever among you, eagle-eyed and generally cussed."
This has been vital for my mega-game. One area is a wax museum under surveillance; one is a magical area with spells; and another has flashbacks where you a different person in the past. So there are a lot of rules I want to completely ban in one region (like in the spell region magic can teleport you, but I don’t want it to function elsewhere).
Section 7.12 is In the Presence of and when
Okay, so this is where in the presence of is defined! Haven’t used it before. Apparently it’s when two people or things are in the same location:
Instead of doing something other than looking, examining or waiting in the presence of the Queen: say "I'm afraid they take what you might call a zero tolerance approach to breaches of court etiquette here."; end the story saying "You have been summarily beheaded"
You can also use ‘when’ in an instead statement which just functions like an ‘if’ clause with any condition:
Instead of eating something when the radio set is switched on, say "Something about the howling short-wave static puts you right off luncheon."
Or if you only want that in the room that actually has the radio:
Instead of eating something in the presence of the radio set when the radio set is switched on, say "Something about the howling short-wave static puts you right off luncheon."
Example 98 is Beachfront. This is a crucial example that does something players often want to do: make an object that isn’t there until you search something else:
The heavy oak desk is a supporter in the stuffy office. It is scenery. Understand "paperwork" as the desk.
The creamy envelope is an openable container. The description is "There is no return address on the outside of the envelope, just the address of the Doctor's office -- but the legs of the capital A are rubbed down in a characteristic way, and the top of every R is open. There's no question that it comes from the same typewriter as the blackmail note." In the envelope is a letter. The envelope can be found or lost. The envelope is lost.
Instead of searching the desk when the envelope is lost:
now the envelope is found;
say "You rifle through the piles of bills and notices; invitations to conventions; advertisements for high-end prescription drugs; pink carbon sheets bearing patients['] names and medical identification numbers in spidery, elderly handwriting. Almost at the bottom of the heap, you find what you were looking for: a creamy envelope with the address typed.";
move the envelope to the desk.
Instead of searching the desk:
say "Further investigation of the desk reveals nothing else suspicious."
Notice that we have two rules that apply to “searching the desk”, but one of them has a more specific set of parameters (“when the envelope is lost”). This means that Inform will consult that rule first and use it if it applies; it will only carry out our plain vanilla “instead of searching the desk” rule when the more restricted rule is not relevant.
Example 99 is Today Tomorrow:
Instead of eating something in the presence of the chihuahua:
say "[The chihuahua] yips at you! Maya looks despairingly at [the noun], which is obviously inciting it."
This example also introduces time of day:
Rule for deciding the concealed possessions of someone (called carrier):
if the particular possession is the chihuahua and the carrier wears the trenchcoat, yes;
otherwise no.
The time of day is 11:45 AM.
At 11:47 AM: say "Your boss pokes his head in, temporarily free of the round of conference calls that occupy all his days. 'Maya,' he says. 'Your coat?' He shakes his head, clucking sadly. 'It doesn't say professional!' But mercifully Maya manages to take it off so slowly that he doesn't glimpse her pet before her phone rings again.";
now Maya carries the trenchcoat.
Section 7.13 is Going from, going to.
Going has special text to distinguish when you care about the destination from when you care about the origin:
The Catalogue Room is east of the Front Stacks. South of the Catalogue Room is the Musicology Section.
Instead of going nowhere from the Front Stacks, say "Bookcases obstruct almost all passages out of here."
Instead of going nowhere, say "You really can't wander around at random in the Library."
Before going to the Catalogue Room, say "You emerge back into the Catalogue Room."
It includes this gem (another crucial thing for new players and cementing this chapter as ‘the best first chapter’ for me):
Note that “going nowhere” means trying a map connection which is blank, and if no rules intervene then “You can’t go that way” is normally printed. Unless “nowhere” is specified, descriptions of going apply only when there is a map connection. So “going from the Musicology Section” would not match if the player were trying to go east from there, since there is no map connection to the east. Similarly, “going somewhere” excludes blank connections.
You can use regions instead of rooms for ‘to’ and ‘from’.
If you type something like this in a region:
Instead of going north in the Wilderness, say "Oh, it's too cold."
Inform parses it as ‘Instead of going north when the player is in the Wilderness’ (here the Wilderness is a region).
You can’t use instead rules for variables in this way (this does not compile):
The Dome is a room. The Hutch is north of the Dome. The rabbit is in the Hutch. Before going to the location of the rabbit, say "You pick up a scent!"
But this does:
The Dome is a room. The Hutch is north of the Dome. The rabbit is in the Hutch. Definition: a room is rabbit-infested if it is the location of the rabbit. Before going to a rabbit-infested room, say "You pick up a scent!"
I’ve noticed that pretty much any complicated thing that won’t compile works well as an adjective. (well, at least a couple of times it has worked).
Lots of examples, including the glamorours example 100!
Veronica:
Neptune is a region.
Tijuana is a room.
High School is north of Tijuana. It is in Neptune.
Detective Offices is west of High School. It is in Neptune.
The player is in High School.
Instead of going from Neptune to a room which is not in Neptune:
say "It's a bad time to leave Neptune."
Is this a reference to something?
Example 101 is A&E:
Film Set is a region. Duck Pond, Stately Lawn, and Stately Home are in Film Set.
Instead of going to Film Set when the player does not carry the VIP Pass: say "A burly studio guard materializes in your path, convincing you that you would prefer to be elsewhere."
Example 102 is Bumping into Walls, a deeply useful example that tells the player available exits if they go the wrong way:
Definition: a direction (called thataway) is viable if the room thataway from the location is a room.
Instead of going nowhere:
let count of exits be the number of viable directions;
if the count of exits is 0, say "You appear to be trapped in here." instead;
if the count of exits is 1, say "From here, the only way out is [list of viable directions].";
otherwise say "From here, the viable exits are [list of viable directions]."
Example 103 is Polarity:
The former location is a room that varies.
First carry out going rule:
now the former location is the location.
Understand "go back" as retreating. Understand "back" or "return" or "retreat" as retreating.
Retreating is an action applying to nothing.
Carry out retreating:
let way be the best route from the location to the former location, using doors;
if way is a direction, try going way;
otherwise say "You can't see an open way back."
When play begins: now the former location is the Dome.
Instead of retreating when the former location is the location: say "You haven't gone anywhere yet."
This is the first example of the phrase ‘first carry out…’, which I never use but we’ll see more later.