If I have a doggy door, I want to be able to open it and have it close
after I go through. AutoClosingDoor does that just fine. However, if I
open the door and then leave the room without going through then come
back and examine the door, it'll say that the door is still open.
I'd rather have it close when the player leaves the room. If it stays
open while in the room then it can be assumed that the player was
holding it open, so no problems there.
This might actually have an effect on things if the there is a sense
connector through the door. (You can see things on the other side of
the door when the flap is open.)
There's probably more than one way to do this. One way would be to
put something like the following on your AutoClosingDoor:
beforeTravel (traveler, connector)
{
if(connector != self)
{
makeOpen(nil);
"As you leave, you see <<theName>> swing shut. ";
}
}
-- Eric
- It closes after a specified time after being opened. (Duh)
- If the player "opens the door" before it fully closes, the timer
restarts. That is, a player can catch the door before it closes.
- If a player can see the door shut, it lets them know (via closeMsg).
- The door can be made to lock automatically upon closing (via
autoLocking). (Though you need to add Lockable to the class list)
- It's easy to modify the behaviour (you can change canSenseAutoClose
so that a PC only has to be within *hearing* range).
There may be bugs, and comments are sparse, so beware.
Cheers,
BrettW
// Timed Autoclosing door.
// This is a different kind of autoclosing door. Upon opening, it sets up a
// fuse to shut the door. Imagine this as a swinging door that slowly
slides
// shut.
class TimedAutoClosingDoor : Door
closeTime = 3
closeMsg = "\^<<self.theName>> slowly closes by itself and clicks
shut. "
closeFuseID = nil
isAutoLocking = true
autoClose() {
makeOpen(nil);
if(canSenseAutoClose )
closeMsg;
}
autoLock() {
makeLocked(true);
}
canSenseAutoClose() {
return (gPlayerChar.canSee(self) || gPlayerChar.canSee(otherSide) );
}
makeOpen(stat) {
inherited(stat);
/* Set up the autoclosing fuse */
if (stat) {
if(closeFuseID != nil)
closeFuseID.removeEvent;
closeFuseID = new Fuse(self,&autoClose, closeTime);
}
else {
if(closeFuseID != nil)
closeFuseID.removeEvent;
closeFuseID = nil;
if(isAutoLocking)
autoLock();
}
}
dobjFor(Open) {
action() {
if(isOpen)
"You catch the door before it closes and open it again. ";
inherited();
}
}
;