12.10. Action variables

| Chapter 12: Advanced Actions |

| 12.10. Action variables

For some complex situations, it can be useful to keep track of a few values throughout the processing of the action. This is not an everyday occurrence: in the Standard Rules, for instance, only two or three out of 90 actions need to do this. But suppose we want to write a more deluxe version of our "photographing" action. This time, rather than having a single thing called the "camera", we will provide a whole range of possible cameras, varying in quality:

> Photographing is an action applying to one visible thing and requiring light. Understand "photograph [something]" as photographing.

> The Studio is a room. Sally is a woman in the Studio. A foam-lined tote bag is in the Studio.

> A camera is a kind of thing. A camera has a number called picture quality. The digital SLR camera is a camera in the tote bag. The player carries a camera called the instant one-shot camera. The picture quality of the SLR camera is 10. The picture quality of the one-shot is 2. Definition: a camera is sharp if its picture quality is 5 or more.

And we will want the photographing action to have the player use the best-quality camera which comes to hand. We will give the action a variable called the 'camera photographed with', thus:

> The photographing action has an object called the camera photographed with.

Every action's variables must be named differently from those of all other actions, because there are some "before" rules (for instance) which take effect for many different actions, and which might need access to any of their variables. So action variables should be named in a way marking out to which action they belong. The best way to do this is to include the past participle of the action name - just as "camera photographed with" contains the past participle "photographed" of the action "photographing".

This value is created when the action begins, and disappears when the action ends. (If the action should happen a second time before the first time was completed, a second copy of the value is created, leaving the original undisturbed.) When the action begins, the value starts out as something neutral - so if it is a number, it starts out as 0, if a text, it starts out as the blank text "", and so on. Here it is an object, so it starts out as nothing - the value meaning no object at all. But of course we want to give it a value ourselves. We can do that using the "setting action variables" rulebook. For instance:

> Setting action variables for photographing:
> now the camera photographed with is the sharpest camera which is carried by the actor.

The "setting action variables" rulebook is run through before even the before rules, and it has no power to stop or change the action. Its rules should say nothing and do nothing other than to set rulebook variables like this one. Note that it is intended to work for any actor, not only the player: so rather than referring to the player as the performer of the action, we need to write "the actor", as in the example above. (See subsequent sections for more on actors.)

We can now write rules such as:

> A check photographing rule:
> if the camera photographed with is nothing:
> say "You can hardly photograph without a camera, now can you?" instead.

Only rules to do with the photographing action - before, instead, after, check, carry out, or report rules, and so on - are allowed to see the 'camera photographed with' value: it's the private property of the action.

A further elaboration allows us to make rules about photographing neater to write. If we create our variable like so:

> The photographing action has an object called the camera photographed with (matched as "using").

...then we are now allowed to add an optional 'using ...' clause onto a description of the action. The clause has to be introduced with a single word: here, it's 'using'. For instance, we could write rules such as

> Instead of photographing something using the one-shot camera:
> say "But you promised to give this to Sally's nephew."

> Check photographing something using the noun:
> say "That would require some sort of contraption with mirrors." instead.

> Report photographing something using a sharp camera:
> say "You feel cool and important as the shutter clicks."

(This is the method used by the Standard Rules to attach optional clauses such as 'to', 'with' and 'through' to the going action.)

198
| Example Further Reasons Why All Poets Are Liars The young William Wordsworth, pushing a box about in his room, must struggle to achieve a Romantic point of view. |
RB

We begin with the location and its fittings, and we create a kind of value which names the different internal positions we will allow. "Further Reasons Why All Poets Are Liars" Nook Obscure is a room. "Above the College kitchens, which make a humming sound, less tuneable than bees, but hardly less industrious, with shrill notes of sharp command and scolding intermixed: and below Trinity's loquacious clock, who never lets the quarters, night or day, slip by him unproclaimed, and tells the hours twice over with a male and female voice. In short, the kind of rubbish room they give to a northern villager. But you get a bed and a high shelf all of your own. And you long to find some Romantic way to look out of the window." The window, the shelf and the bed are scenery in the Nook Obscure. The shelf and the bed are supporters. The bed is enterable. Internal position is a kind of value. The internal positions are nowhere at all, over by the window, under the shelf and near the bed. The box is an enterable supporter in Nook Obscure. The current box position is an internal position that varies. The current box position is near the bed. "Your packing case, stamped W. WORDSWORTH (KENDAL), is [current box position]." Instead of taking the box, say "It is filled with your peerless rock collection and too heavy to lift, but could be pushed." Instead of opening the box, say "It is securely nailed shut." We create an action, "pushing it over to", for pushing a box around on the floor of a single location. (Calling this "pushing it over to" prevents clashes with the existing "pushing it to" action, which is for pushing things from one room to another.) Almost half of the text which defines the action is concerned with the two action variables, but they make the implementation of everything else so much easier that we end up writing less than if we hadn't used them. Understand "push [box]" as a mistake ("You can push the box to the window, the bed or the shelf."). Understand "push [something] to [something]" as pushing it over to. Pushing it over to is an action applying to two things. The pushing it over to action has an internal position called the old position. The pushing it over to action has an internal position called the new position. Setting action variables for pushing something over to something: now the old position is the current box position; now the new position is nowhere at all; if the second noun is the window, now the new position is over by the window; if the second noun is the bed, now the new position is near the bed; if the second noun is the shelf, now the new position is under the shelf. Check pushing it over to: if the noun is not the box, say "That's not something you can push." instead; if the player is on the bed, say "You can't reach from here." instead; if the player is on the noun, say "Not while you are standing on [the noun]." instead; if the new position is nowhere at all, say "You can only push [the noun] to the window, the bed or the shelf." instead; if the new position is the old position, say "The [noun] is already [new position]." instead. Carry out pushing it over to: now the current box position is the new position. Report pushing it over to: say "With some effort, you shove [the noun] from [old position] to [new position]." Everything which remains simply provides a couple of puzzles to test this arrangement. Euclid's Elements is on the shelf. Understand "euclid" or "book" as the Elements. Instead of taking something (called the item) which is on the shelf: if the player is on the box and the current box position is under the shelf, continue the action; say "You cannot reach [the item], which is up on the shelf." Instead of examining the window: say "This window opens rather unpromisingly onto the chapel wall opposite, so even granted the moonlight it is dark in here. Still, surely there's a poem here somewhere?" Instead of examining the window when the player is on the bed: say "Just a blank patch of chapel wall." Instead of examining the window when the player is on the box: if the current box position is near the bed: say "Tantalisingly, you are not quite able to spy the statue."; otherwise if the current box position is under the shelf: say "All you can see is the antechapel wall, and the dull silver gleam of the pealing organ."; otherwise: say "At last! You can just, standing on tiptoes on the box right up at the window, make out the top of the statue! Of such epiphanies are Poesy born. Let's see now... oh yes...[paragraph break]And from my pillow, looking forth by light[line break]Of moon or favouring stars, I could behold[line break]The antechapel where the statue stood[line break]Of Newton with his prism and silent face,[line break]The marble index of a mind for ever[line break]Voyaging through strange seas of Thought, alone."; end the story finally. Test me with "get on bed / x window / get off / x window /get elements / get on box / x window / get elements / push box to shelf / get off / push box to shelf / get on box / get elements / x window / get off / push box to window / get on box / x window".

199
| Example The Second Oldest Problem Adapting the going action so that something special can happen when going from a dark room to another dark room. |
RB

200
| Example Removal TAKE expanded to give responses such as "You take the book from the shelf." or "You pick up the toy from the ground." |
RB

201
| Example Puff of Orange Smoke A system in which every character has a body, which is left behind when the person dies; attempts to do something to the body are redirected to the person while the person is alive. |
RB

202
| Example Croft Adding special reporting and handling for objects dropped when the player is on a supporter, and special entering rules for moving from one supporter to another. |
RB

Previous | Contents | Next