Automatically Unlocking Rooms

There is an area on Furcadia called FurN that is home to very particular kinds of dreams that need very particular kinds of DS. One of the things that most dreams in FurN have in common is that they have a set of lockable rooms for private 'conversations'. These lockable areas however pose a great risk to the dream owner, since they may stay locked even after all the furres inside have left (some furres even take pleasure in locking all rooms in a dream just to spite the owner).

Over time various methods appeared to make the rooms unlock again. A room-check is one method used, where a staff-member of the dream briefly pops into each of the rooms, checking whether there are furres inside and, if not, unlocking the door. A second method is to automatically unlock the rooms after a certain time, usually combined with a message to anyone in the room so that they can relock the room.

All of these methods have one thing in common though. They interrupt whatever goes on in the room. In the first case you get an unwanted visitor (however briefly). In the second case you're forced to get up and hit the switch again to lock the room. Either way it disrupts the flow of conversation. I felt it could be done better.

This section details some DS that automatically unlocks the room within at most 20 seconds of the last furre leaving the room, regardless of how the furre left the room. This is done in three parts. The first part explains how to lock the room. The second part deals with how we detect the presence of furres in the room. Finally, in the third part, we combine the two into automatically unlocking room DS.

Locking the room

We'll do the easiest part first, which is locking the room. For this we'll use a few of the standard Furcadia items:

161162542543

When the room is unlocked the switch is green (161) and the door is black (543). When the room is locked the switch is red (162) and the door is red as well (542). When a furre bumps into the switch we want to toggle between a locked room and an unlocked room. Furthermore, we want furres to be able to move in and out of the room, but only if it is unlocked.

This leads to the following blocks of dragonspeak:

* lock/unlock the room
(0:7) When somebody moves into position (14,21),
(3:2) at position (14,21) on the map,
(5:6) swap object types 161 and 162.
(3:2) at position (20,21) on the map,
(5:6) swap object types 542 and 543.
(3:2) at position (18,19) on the map,
(5:6) swap object types 542 and 543.

* teleport a furre from the hallway to the room (if the door is unlocked)
(0:7) When somebody moves into position (18,20),
(1:1013) and position (14,21) is object type 161,
(5:15) move the triggering furre to (16,18), or to someplace nearby if it's occupied.

* teleport a furre from the room to the hallway (if the door is unlocked)
(0:7) When somebody moves into position (18,19),
(1:1013) and position (14,21) is object type 161,
(5:15) move the triggering furre to (20,21), or to someplace nearby if it's occupied.

Furre detection

Now we need a way to determine conclusively whether there's a furre present in the room or not. In the past I experimented with counting the furres that moved into and left the rooms. This worked well enough except when furres were summoned into the room. This turned out to be near-undetectable and forced me to turn on the summon-shield in the dream. It just didn't work comfortably.

Fortunately DEP added some interesting DS lines in the squirrel update: idle triggers. Now we have the means to detect whether a furre is doing something and the means to detect whether a furre is doing nothing. This turns out to be just what we need as we can determine that there is no furre in the room if we can't detect any furres doing anything and any furres doing nothing.

All we need are two DS lines that complimentary, i.e. two ds lines where either one or the other triggers. There are a number of possibilities, but I chose the following two (for a reason I'll explain below):

(0:1) Whenever somebody moves,
(0:71) When a furre stays in the same square for # seconds,

Suppose we set the idle-limit to 10 seconds, then within 10 seconds we'll know whether a furre moved (triggering the first line), whether a furre stayed in the same spot (triggering the second line) or whether there was no furre at all.

In the case of our room, this leads to the following two blocks of DS (or atleast the starts of them):

(0:1) Whenever somebody moves,
(1:81) and the triggering furre is within the diamond (14,9) - (14,21),
* ...movement detected inside the room, so do something

(0:71) When a furre stays in the same square for 10 seconds,
(1:81) and the triggering furre is within the diamond (14,9) - (14,21),
* ...idling furre detected inside the room, so do something
(5:18) move the triggering furre back where they came from.

You're probably wondering why I move the triggering furre back in case he stays in the same square. It turns out that the (0:71) cause doesn't trigger every 10 seconds if a furre stays in the same square for long periods of time. Experimentation has shown that it will trigger 3 times, then wait about a minute or more before triggering again. This would be disastrous to our DS as we won't be able to reliably tell whether there's a furre in the room anymore. Fortunately we can fool the system by moving the furre back to where he is already sitting, thus causing the cycle of 3 to restart, thus making sure that it triggers for certain every 10 seconds.

WARNING!

Moving the triggering furre back where they came from is regarded as movement by Furcadia. This means that "(0:71) When a furre stays in the same square for # seconds," will not trigger for the rest of the dragonspeak file.

Should this be a problem, it is possible to remove the "(5:18) move the triggering furre back where they came from." line from the above block of dragonspeak and instead place the following block at the end of your dragonspeak file (with the correct idle time ofcourse):

(0:71) When a furre stays in the same square for # seconds,
(5:18) move the triggering furre back where they came from.

Putting it together

So let's put the two together to complete our automatically unlocking rooms. We'll do this by using a countdown timer. Whenever a furre is detected inside the room, we'll set the countdown timer to trigger in 20 seconds. Since we detect a furre's presence within at most 10 seconds, this countdown timer keeps getting reset before it can run out. Only when there are no more furres left will the countdown timer end up triggering, unlocking the room in the process.

Combining the above ideas with the DS for the room-locks and the furre-detection leads to the following complete DS for an automatically unlocking room:

* teleport a furre from the hallway to the room (if the door is unlocked)
(0:7) When somebody moves into position (18,20),
(1:1013) and position (14,21) is object type 161,
(5:15) move the triggering furre to (16,18), or to someplace nearby if it's occupied.

* teleport a furre from the room to the hallway (if the door is unlocked)
(0:7) When somebody moves into position (18,19),
(1:1013) and position (14,21) is object type 161,
(5:15) move the triggering furre to (20,21), or to someplace nearby if it's occupied.

* lock/unlock the room
(0:7) When somebody moves into position (14,21),
(3:2) at position (14,21) on the map,
(5:6) swap object types 161 and 162.
(3:2) at position (20,21) on the map,
(5:6) swap object types 542 and 543.
(3:2) at position (18,19) on the map,
(5:6) swap object types 542 and 543.

* unlock the room if the timer goes off.
(0:50) When countdown timer 1 goes off,
(5:41) place object type 161 at (14,21).
(5:41) place object type 543 at (20,21).
(5:41) place object type 543 at (18,19).

* movement inside the room -> reset the timer
(0:1) Whenever somebody moves,
(1:81) and the triggering furre is within the diamond (14,9) - (14,21),
(5:50) set countdown timer 1 to go off in 20 seconds.

* 'idling' furres inside the room -> reset the timer
* in addition, perform a small trick to make sure that the idle trigger keeps triggering every 10 seconds
(0:71) When a furre stays in the same square for 10 seconds,
(1:81) and the triggering furre is within the diamond (14,9) - (14,21),
(5:50) set countdown timer 1 to go off in 20 seconds.
(5:18) move the triggering furre back where they came from.

Conclusion

This method of locking/unlocking the rooms may seem a bit more work than most would want to put into room-DS, but remember: once it's written, you'll never have to worry about locked rooms anymore. To me, that makes these 24 lines of DS seem like a small price to pay.

P.S. A sample dream demonstrating the DS made here is available in the small box at the top.