| Chapter 12: Advanced Actions |

| 12.10. 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?

> >clark, photograph me
> >

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 then say "You can hardly photograph without a camera, now can you?" instead.

the action is "photographing", not "Clark trying 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 game which has no other characters who succumb to persuasion, for instance, only the player will ever try the action.

166
| Example The Man of Steel An escaping action which means "go to any room you can reach from here", and is only useful to non-player characters.

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: "The Man of Steel" Escaping is an action applying to nothing. Carry out someone trying 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 trying going way. Every turn: if Clark Kent can see kryptonite, try Clark Kent trying escaping. The Daily Planet Newsroom is a room. 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".

167
| Example Trying Taking Manhattan Replacing the inventory reporting rule with another which does something slightly different.

168
| Example Under Contract Creating a person who accepts most instructions and reacts correctly when a request leads implicitly to inappropriate behavior.

Previous | Contents | Next