Inform: Implementing a semi-realistic car


Fri, 18 Aug 1995 16:18:00 +0100

I seem to have come up against some inadequacies in the Inform library (or
quite possibly my understanding of it), and require help. There follows a
long and poorly-written explanation of my problem. Sorry there's no example
code, but it's quite long too. If you think you can and want to help email
me and I'll mail you the code.

I'm trying to implement a semi-realistic car. By this I mean a car which the
player can:

(a) enter/exit if it's unlocked,
(b) lock/unlock {if the player's outside he needs the key, inside no key
is needed),
(c) switch on/off (only if the player's inside. He needs the key to
switch it on. If the car's on the key is in the ignition, so `GET
KEY' or `SWITCH OFF CAR' both retrieve the key and turn off the
engine).

Opening/closing car doors is done automatically as necessary.

The problem is using the standard Inform properties and verb subroutines is
more trouble than it's worth. For instance, to make the car enterable it
needs to be open, but to have it lockable it needs to be closed. I can get
around this with a bit of hacking, but it's no less problematic than ignoring
the standard properties/routines and just using before routines for all verbs
which apply to the car. Therefore, I've decided to forget all these
standards and code the whole thing using before/after routines.

Now, I also want to have it so that when you `LOOK' while in the car it
describes the interior, and also everything in the location outside the car
is in scope, but obviously not takeable, etc. Naturally the car can be
driven and so on.

In order to do all this I think it's best to make the car interior a
location (`real_car'), while also having a static object (`fake_car') which
is what is seen from the outside and what is referred to by the player.
Thus, `fake_car' is a child of the location which is pointed to by the global
variable `car_location'. If the player enters `fake_car' then he is moved to
`real_car'. If he exits the car he is moved back to `car_location'.
`car_location' and its contents are always in scope when the player is in the
car, but can only be examined. The contents of the car can be seen by `LOOK
INSIDE CAR' when location = car_location. If the car is driven to a new
location the car_location becomes the new location.

I hope I've explained everything. If anyone has understood this rather
lacking explanation my questions are:

(a) is this a reasonable way to go about this (alternatives?),
(b) could you please give me an explanation of how to change the scope
rules? I don't really follow the one in the manual.

If you'd like to help (please!) but find this explanation utter gibberish
email me and I'll send a better explanation and the code I've written so far.

--
Julian Arnold jools@arnod.demon.co.uk