mirror of
https://github.com/ganelson/inform.git
synced 2024-07-18 06:54:26 +03:00
31 lines
1.7 KiB
Plaintext
31 lines
1.7 KiB
Plaintext
** Making actions work for other people
|
|
(Escape action for non-player characters only; 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 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 going way.
|
|
|
|
Every turn:
|
|
if Clark Kent can see kryptonite, try Clark Kent 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".
|