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 jo...@arnod.demon.co.uk
Hope this helps.
--
============================================
Without my guitar, I am a poet without arms.
- Michael Bloomfield
============================================
> I think you need to look at locked attribute too. The car needs
> locked lockable container transparent and open attributes. You
> are trying to do with open attribute what should be done with locked
> attribut. Oh, and it should have the enterable attribute. Wtih
> transparent attribute the contents of the car can be seen from outside.
This is where I ran into problems. Some of these attributes cause problems
when you try to use them in conjunction with others. The simplest example is
if you want to lock a lockable object it must also have ~open, whereas to
enter an enterable object it must be open. Therefore, if I have an object
which has lockable enterable, but don't want to explicitly use `OPEN/CLOSE
<OBJECT>' I need a before routine in the object definition, something like:
before [;
Open, Close:
"[There's no need. This is done automatically by the game as \
necessary.]";
Lock, Unlock:
give self ~open;
rfalse;
Enter:
give self open;
],
I know this looks reasonably simple, but believe me it causes further
problems! Anyway, I wont' try to re-explain the situation. If anyone
doesn't believe me just try writing your own car which does everything I've
implied previously. It's damn difficult (prepares to eat his words). I
think that the library, while continually improving and making it far easier
to do things `by the book', as it gets more specific, is becoming more of a
hindrance than a help when trying to code something out of the ordinary. Or
maybe it's just me...
--
Julian Arnold jo...@arnod.demon.co.uk
> I'm trying to implement a semi-realistic car.
[Whitters on at some length.]
Well, it seems to be a habit to answer my own posts. 8) I had a sudden and
unexpected bout of understanding, and have now implemented most of the car in
the way I suggested last time (ie, `real_car' location, `fake_car' object and
`car_location').
However, I'm still not clear on how I place objects from one location in
scope in another location without actually moving them all. Does anyone
know?
Thanks,
Jools
--
Julian Arnold jo...@arnod.demon.co.uk
Object the_taxi "yellow taxi"
with name "taxi" "cab" "yellow" "car",
description "It's a shiny yellow taxicab, with the typical black
checkers on the sides. A glowing light atop the cab
says ~YELLOW CAB~ with a phone number under it.",
before [;
Enter, Go: PlayerTo(lone_taxi);
rtrue;
],
has static;
Object lone_taxi "Taxi Backseat"
with description ....
etc.
So typing "enter taxi" or "go in taxi" will move the player inside of
it. (actually to the room 'lone_taxi'). And, furthermore...
Object lone_taxi "Taxi Backseat"
with out_to [;
if (the_taxi has general && motivated(tdriver) == 1)
"~Hey! Not until you pay,~ declares the taxi driver.";
StartTimer(lone_taxi, 5);
return parent(the_taxi);
],
...etc.
I give the_taxi general after it has driven and the driver needs
payment. Ignore the motivated() routine. It just returns 0 if his mind
is being controlled by the player, else 1. After the player exits the
taxi, the timer starts. In 5 turns, the taxi drives off.
Anyway, before I go too far off the tangent.. that is basically it.
Make an "Enter, Go:" in your before routine, and you can enter the car
with no problem. As far as turning it on and driving it, I leave that
to you. :)
--
--- Sam Hulick ------------- shu...@indiana.edu ---------------------
Systems Consultant | Homepage:
Indiana College Placement | http://copper.ucs.indiana.edu/~shulick/
and Assessment Center | PGP public key available on request
Give your car location an `add_to_scope' property (see the Inform
Library history, item 14. For example:
Object Car "car"
with ...,
add_to_scope [;
ScopeWithin(real_car_location);
],
before [;
if (self hasnt open && action ~= ##Examine) {
if (MaxBox(noun) == real_car_location ||
MaxBox(noun) == real_car_location)
"You can't reach that, because the window is shut.";
}
];
[ MaxBox o;
do {
o = parent(o)
} until (o == 0 || parent(o) == 0 || (o ~= player &&
o hasnt transparent && o hasnt supporter && o hasnt open));
return o;
];
--
Gareth Rees
> Give your car location an `add_to_scope' property (see the Inform
> Library history, item 14. For example:
Yes, this is one of the places where I fell down. I assume you've just made
a typo. 8) `add_to_scope' can't be used in a location definition as it is
aliased with `se_to'. But using it with the `fake_car' object does the
trick. Thanks.
--
Julian Arnold jo...@arnod.demon.co.uk