Re: Inform parser problem


09 Jul 1995 15:44:11 GMT

Jason Dyer <jdyer@indirect.com> wrote:
> This isn't exactly the whole problem, but it focuses what I'm stuck on.
> I need something that is password activated, in other words, something will
> happen if you type
>
> PASSWORD
> or
> SAY PASSWORD
> or
> SAY "PASSWORD"
> or
> DOOR, PASSWORD
>
> However, the only one I can manage to implement is the second one. This
> is frustrating me to no end. Can someone help?

Suppose the password is `foo'. Then you can get the first to work using
something like:

[ FooSub;
if (location ~= Rodent_Factory)
"Nothing happens.";
if (Rodent_Door has open) "The door is already open.";
give Rodent_Door open;
StartDaemon(Rodents);
"The door opens.";
];

Verb "foo" * -> Foo;

To make the third form work, try the following piece of magic:

[ Quote;
if (buffer->(parse->(wn*4+1)) == '"') { wn ++; return 0; }
return -1;
];

[ SaySub;
if (special_word == 'foo') <<Foo>>;
"Nothing happens.";
];

Extend "say"
* Quote special Quote -> Say;

To make the fourth form work, note that if you type `object, thing not
understood', then the object's `life' routine is called with `action'
set to `##Answer' and `verb_wordnum' set to the first word in the `thing
not understood'. So you can try the following:

Object Door "door" Rodent_Factory
has door scenery talkable lockable openable locked
with ...
life [;
Answer:
wn = verb_wordnum;
if (NextWord() == 'foo') <<Foo>>;
"~That isn't the right password,~ says the door.";
],
...

--
Gareth Rees