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:
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:
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):
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):
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.
Putting it together
So let's put the two together to complete our automatically unlocking rooms. The way we'll do this is by adding a third state to the switch. This state will be between red and green and we use the following custom item for it:
When the switch is yellow, it means that the room is still locked, but our DS is considering unlocking it unless it detects a furre in the room soon. Since the room is still locked, bumping into a yellow switch will result in unlocking the room (turning the switch to green and the door to black). Furthermore, every 10 seconds we'll change the red switch to yellow. If we detect movement or idling within the room, we'll change the yellow switch back to red. If another 10 seconds pass and the switch is still yellow, then obviously there were no furres inside the room anymore and the room can be unlocked completely.
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:
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 31 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.