Re: Inform: spacial oddity


26 Aug 1995 10:49:54 GMT

In article <19950822.201127.84@arnod.arnod.demon.co.uk>, jools@arnod.demon.co.uk says...
>
>I'm unsure of the use of the `direction' attribute. In the manual it says "A
>direction object ... should have the `direction' attribute." but the
>`compass' objects (`n_obj', etc.) in `parser' don't have this attribute.
>Does anyone know why this is? Is this attribute redundant?
>--
>Julian Arnold jools@arnod.demon.co.uk

My guess is that the direction attribute is on its way out. The
current library already makes it obsolete. The only line in the library
that refers to it is in the grammar for "go":

>Verb "go" "walk" "run" "leave"
> * -> VagueGo
> * direction -> Go
> * noun -> Enter

But since (as you pointed out) none of the standard directions have the
'direction' attribute,

>go north

is routed to EnterSub (not GoSub). EnterSub doesn't check for
'direction' (it might have, once upon a time, I don't know), but
rather checks to see if the noun is in the 'compass' object (as all
the directions are). If it is, it passes the noun on to the Go action.

When a player types one of the directions on its own, as in:

>north

the library deals with it internally as a special case (see parser.h
around line 712), checking to see if the word typed matches a noun
that is inside the compass--again, ignoring the 'direction' attribute.

So, if you are adding your own directions, or replacing the library's
directions with your own, you can safely ignore the 'direction'
attribute, just as long as you put your new direction(s) in the compass
(and why wouldn't you?).

Personally, I keep the 'direction' attribute so that I can have grammar
like:

Extend "look" first
* direction -> View;

(To print an appropriate response when the player types, say:
>look northwest)

But even here, I could have instead used a routine token to check if the
noun is in the compass.

In fact, with the way the libray currently handles things, the only use
I have been able to find for the direction attribute is for an object
that you can "go" but not "enter", that is not in the compass, and, in
fact, is something that you can "go" even while you're carrying it.

For example:

Nearby bananas "bananas"
with
name "bananas" "bunch",
article "some",
door_dir [ x;
print "[Good move. Nothing else has worked.]^";
print "^>go south^";
<Go s_obj>; new_line;
if(children(player)>0) {
print ">drop ", (name) child(player), "^";
<drop child(player)>; new_line;
}
if(children(player)>1) {
print ">put ", (name) child(player),
" in ", (name) sibling(child(player)), "^";
<Insert child(player) sibling(child(player))>;
new_line;
}
print ">go northwest^";
<go nw_obj>; new_line;
print ">sing^";
<sing>; new_line;
print ">damn^";
<mild>; new_line;
print ">go east^";
<go e_obj>; new_line;
print ">get all^";
objectloop (x in location) {
print (name) x, ": "; <Take x>;
}
new_line;
if(children(player)>0) {
print ">attack ", (name) child(player), "^";
<attack child(self)>;
new_line;
}
print ">go north^";
return n_to;
],
has edible direction;

Michael Graham

--
magog@the-wire.com