I would like to be able to say "Set dial to 32" or "Turn dial to 32".
The grammer for the Set verb in the grammar.h library file uses
the special token. (In one place the Designer's Manual says that the
special token is "obsolete and best avoided", and in another that it
matches
any single word or number.)
I'm not sure how to be sure that I only accept "Set dial to <number>"
and not "Set dial to fred" or some object name. I would like to be able
to
restrict the setting for my dial object without restricting those for
other
set-able objects, which might allow more general settings. Is there an
easy way to accomplish this?
It seems impossible in the SetTo case of the before routine for the dial
to distinguish between a number and some object (which also equates to a
number)?
(If anyone has any examples of something like this, a code snippet would
be
greatly appreciated!)
Thanks!
Sam Roberts
Sure. Here's the code for the dial from Varicella:
Object -> dial "dial"
with name 'channel' 'selection' 'dial',
number 0,
describe [; rtrue; ],
description [;
"This is a simple dial, numbered from 0 to 45. It is currently
set to ", self.number, ".";
],
before [a;
if (painting in vwall) "The dial is currently hidden by the
oil painting on the wall.";
if (panel hasnt open) "The dial is currently hidden by the
panel designed for that purpose.";
Turn, Set: "You must specify a number from 0 to 45.";
SetTo: a = special_number;
if (a > -1 && a < 46) {
self.number = a;
"You set the dial to ", self.number, ".";
}
"The dial must be set to a number between 0 and 45.";
],
has static;
-----
Adam Cadre, Sammamish, WA
web site: http://adamcadre.ac
novel: http://www.amazon.com/exec/obidos/ASIN/0060195584/adamcadreac
Extend 'set' first * noun 'to' number -> SetToNumber;
The word "first" tells the parser to evaluate this rule before it tries
any of the other rules for this verb. Thus, you'll parse numbers as
numbers (and send them to and everything else as "special".
Note that that if you use the grammar line above, you'll have to define
the default response through a routine "SetToNumberSub".
Sent via Deja.com http://www.deja.com/
Before you buy.