| ANSWER TO EXERCISE 31 | |
|
Martha and the sealed room are defined as follows:
Object sealed_room "Sealed Room"
with description
"I'm in a sealed room, like a squash court without a door,
maybe six or seven yards across",
has light;
Object -> ball "red ball" with name "red" "ball";
Object -> martha "Martha"
with name "martha",
orders
[ r; r=parent(self);
Give:
if (noun notin r) "~That's beyond my telekinesis.~";
if (noun==self) "~Teleportation's too hard for me.~";
move noun to player;
"~Here goes...~ and Martha's telekinetic talents
magically bring ", (the) noun, " to your hands.";
Look:
print "~", (string) r.description;
if (children(r)==1) ". There's nothing here but me.~";
print ". I can see ";
WriteListFrom(child(r),CONCEAL_BIT+ENGLISH_BIT);
".~";
default: "~Afraid I can't help you there.~";
],
life
[; Ask: "~You're on your own this time.~";
Tell: "Martha clucks sympathetically.";
Answer: "~I'll be darned,~ Martha replies.";
],
has animate female concealed proper;
but the really interesting part is the InScope routine to fix
things up:
[ InScope actor;
if (actor==martha) PlaceInScope(player);
if (actor==player && scope_reason==TALKING_REASON)
PlaceInScope(martha);
rfalse;
];
Note that since we want two-way communication, the player has to
be in scope to Martha too: otherwise Martha won't be able to
follow the command "martha, give me the fish'', because "me''
will refer to something beyond her scope.
|