Chapter 12: Advanced Actions
12.20. Stored actions

As we have seen, to describe an action fully takes a complicated little bundle of information - we need to know what is to be done, who will do it, and what it will be done to. There are times when we would like to remember an action and look back on it later (perhaps many turns later, after many other actions have taken effect) - but this is not easy to do with only the techniques we have seen so far. There are quite a few cases to get right, and it would be easy to not store quite enough of the details.

Fortunately, Inform provides a kind of value called "stored action" which can do all of this automatically. As with most other kinds of value, stored actions can be held in variables, "let" values, properties or table columns. For example:

The best idea yet is a stored action that varies.

creates a variable called "the best idea yet" which holds a stored action. This will normally be created holding the default value - the player waiting - but can instead be set explicitly:

The best idea yet is the action of pushing the button.

Note the words "action of...", which convert any sufficiently exact description of an action into its stored action form.

In rules and phrases, we can always obtain the action currently going on (if there is one) with the value "current action":

let the present whim be the current action;

Moreover, just as we can "try" any action, so we can also try a stored one:

try the present whim;
silently try the present whim;

would each work in the natural way. A stored action can do anything that actions can do: in particular, they remember, if necessary, the exact wording of the player's command at the time they were stored - so that even actions like "looking up 'x100' in the code book" will work if stored and tried on some future turn.

As with any other kind of value, we can also say a stored action, and this produces a fairly natural description of what the action is:

Before doing something in the presence of the bearded psychiatrist: say "'Zo, the subject wishes to engage in [the current action]. Zis is very interesting.'"

will produce text such as:

"So, the subject vishes to engage in rubbing the fireman's pole. Zis is very interesting."

One of Inform's most convenient features is its ability to test if the action being processed matches vague or complicated descriptions of whole classes of actions. Now, it would not make sense to write

if the best idea yet is the action of taking something, ...

because "action of ..." has to make an exact action, which clearly this is not: so Inform will produce a problem message if we try. But we do not need to, because Inform also allows us to compare a stored action against any description of an action, however vague:

if the best idea yet is taking something, ...
if the best idea yet is doing something to the lever, ...

When dealing with stored actions, we sometimes want to know what they are dealing with. We can extract this information using the following phrases:

action-name part of S
noun part of S
second noun part of S
actor part of S

For example, if S is "Algy trying throwing the brick at Biggles" then saying these four values will produce

throwing it at
brick
Biggles
Algy

Should the action be one which does not involve objects, the noun and second noun may be "nothing": for instance if S is "setting the dial to 3417" then the noun part of S is the dial but the second noun part is nothing. (This has to be true, as otherwise Inform could never know what kind of value "the noun part of S" would have.)

As a convenience, the condition

if S involves X, ...

is true if the object X appears as any of the actor, the noun or the second noun: for instance,

if the current action involves Algy

would be true for "give revolver to Algy", "Algy trying flying the Sopwith Camel", "examine Algy" and so on, but false for "ask Raymond about secret airfield".


202
* Example  Bosch
Creating a list of actions that will earn the player points, and using this both to change the score and to give FULL SCORE reports.

RB
203
* Example  Cactus Will Outlive Us All
For every character besides the player, there is an action that will cause that character to wither right up and die.

RB

"Cactus Will Outlive Us All"

Death Valley is a room. Luckless Luke and Dead-Eye Pete are men in the Valley. A cactus is in the Valley. Persuasion rule: persuasion succeeds.

A person has a stored action called death knell. The death knell of Luckless Luke is the action of pulling the cactus. The death knell of Dead-Eye Pete is the action of Luke trying dropping the cactus.

Before an actor doing something:
    repeat with the victim running through people in the location
    begin;
        let the DK be the death knell of the victim;
        if the DK is not waiting and the current action is the DK
        begin;
            say "It looks as if [the DK] was the death knell for [the victim], who looks startled, then nonexistent.";
            remove the victim from play;
        end if;
    end repeat.

Test me with "get cactus / drop cactus / luke, get cactus / luke, drop cactus / pull cactus / look".

204
** Example  Actor's Studio
A video camera that records actions performed in its presence, and plays them back with time-stamps.

RB
205
** Example  Anteaters
The player carries a gizmo that is able to record actions performed by the player, then force him to repeat them when the gizmo is dropped. This includes storing actions that apply to topics, as in "look up anteater colonies in the guide".

RB


PreviousContentsNext