inform doors.. an alternate method?


7 Nov 1995 05:21:40 GMT

Having just got inform a few days ago, I naturally
jumped right in and started writing a game with no planning
beforehand whatsoever (which makes for a real crappy game,
at least when I try it). I took one look at the usual method
of doing doors (with door_dir and door_to) and said "screw
that." I ended up doing this:

-------------------------- CUT HERE ------------------------

object stuck_outside "Stuck Outside" with
description "You are stuck outside. A tall gate \
stands before you, blocking the way \
north.",
n_to "The gate is shut.",
has light;

nearby gate_key "gate key" with
name "gate" "key",
initial "The gate key is here.",
description "A key. It says ~To gate~ on it. \
Hint hint.";

object gate "gate" with
name "gate",
found_in stuck_outside inside,
before [;
examine:
if (self hasnt general)
"The gate is surely a nuisance!";
"The gate stands open.";
unlock:
if (self has general)
"The gate is already unlocked!";
if (second==gate_key) {
"The gate clicks open.";
give self general;
stuck_outside.n_to=inside;
inside.s_to=stuck_outside;
}
else
"That won't unlock the gate.";
lock:
if (self hasnt general)
"The gate is already locked!";
if (second==gate_key) {
"The gate snaps closed.";
give self ~general;
stuck_outside.n_to="The gate \
is shut.";
inside.s_to="The gate is shut.";
],
has scenery;

object inside "Inside" with
description "Hah. You are inside.",
s_to "The gate is shut.",
has light;

[ initialise;
location=stuck_outside;
];

-------------------------- CUT HERE ------------------------

What advantages does the door_dir/door_to method have
over this? I know my method works fine (as far as I can tell).
I take this opportunity to thank Graham Nelson for
writing such a flexible parser and grammar system.