Home
Up

Sample Dream

One of the most frustrating things one does encounter in dreamweaving is that fact that you have to constantly add lines of DragonSpeak to handle the zillion doors your dream has. And when you need to move a room, or change how the entry / exit works for a room, you need to remember to update your positions in your DragonSpeak. Well, this is not a perfect answer, but it does come pretty close to code it once, never bother with it again type of code for instead of relying on positions hard coded into the DragonSpeak, we instead rely on the design of the dream to handle the teleports.

This particular type of coding does "cost" you something, mainly you lose the ability to use the "teleport objects" elsewhere in the dream for you can only have two of each in the dream. Plus, with this particular chunk, you also need to sacrifice a floor.

Eventually, when your dream is ready for public use, you will most likely want to actually edit the patch items and, well, "zap" them out of existence, mainly just by using the patch editor to select the whole shape, then deleting it. The items used for the door do not have to have any particular FBJ properties, but in this chunk, the floor needs to be a No-Walk floor, you do need the triggering furre to remain where they are for the code uses "at position (x,y), move any furre present to (x,y) or someplace nearby.", so, with that out the way, onwards with the coding.

* // generic door system, heading NE
Okays, for this to work as expected, first I need to designate a "door" floor, for this particular dream, because I'll most likely never use the water floor tile 81, let's pick on it. In the initial weaving of the dream, I'm tagging this with the word DOOR so that I can see where my doors are on the map, and have a verification of which way is going where. In the finished product I will probably replace this with a copy of tile179.
(0:2) When somebody moves into floor type 81,
 (1:13) and the triggering furre is facing northeast (up and right),

Of course, this chunk is only showing you one direction, the full code would contain a direction check for each direction, and have the DS move the variables used in the proper direction for each case, mainly the direction that the triggering furre is moving.
    (5:350) set variable %furrefrom to the X,Y position the triggering furre (moved from/is standing at).
    (5:350) set variable %movefrom to the X,Y position the triggering furre (moved from/is standing at).

We need two positions for the move from and one for the move to, the %furrefrom is where the triggering furre is at, and the %movefrom is where we need to get our teleport marker object from. So the next step is to move the variable %movefrom in the direction the triggering furre moved in by 2 steps, and capture the object we should find there.
    (5:352) move the position in variable %movefrom northeast (up and right) 2 step(s).
    (5:381) set variable %roomobject to the object type at (%movefrom).
    (5:41) place object type 465 (square zero) at (%movefrom).

Once we got our %roomobject, we need to then ensure that the next two lines will only capture the matching object that we want to move the triggering furre to, hence, we need to zap the object on the map, replacing it with another object, or a nothing if you so prefer, so the next two lines get the correct destination for the triggering furre.
    (5:532) set variable %furreto to the X,Y position of a random spot where the object is type %roomobject somewhere in the dream,
    (5:352) move the position in variable %furreto northeast (up and right) 2 step(s).

Once we got our destination, we then move the that position in the direction that the triggering furre is moving, and we got the position that the furre needs to be teleported to. Our final act is to actually move the furre there, (or someplace nearby as done with this code), and reset the door so that the next furre who triggers this DS gets moved as well.
  (3:2) at position (%furrefrom) on the map,
    (5:17) move any furre present to (%furreto), or to someplace nearby if it's occupied.
    (5:41) place object type %roomobject at (%movefrom).

Of course, you can change that last part to "move the triggering furre to" and be rid of the 3:2 in this code as well. You can even have locking doors with a bit more work and thought on how the execution of the code should work. In my case, I intend to "sacrifice" yet another floor, calling it "LOCK", then, using some extra verification steps and a bit of additional code, change out the floors marked DOOR with LOCK for any particular locking instance. To make things more interesting, I will be using the same "object" system to locate the correct floors to change out. This will, of course, end up putting 3 objects on the map, one object on either end of the teleport, and one for the locking system, The object near the lock switch will probably sit over a special floor, then part of the above code will "only where floor X is, change object %roomobject to object Y", which will zap the object for the lock locator off the map first, then there should only be a single object for the DS to find for the destination. Part of the cleanup will be "everywhere on the map, replace object Y with %roomobject"

To effect the locking / unlocking action, the code will use something like the above code to move the triggering furre's position in the direction they were moving by the number of spaces needed to get to where the %roomobject should be, removing that from the map, then use two additional sections to capture each object on the map, move the position in all four directions, and "change floor DOOR to floor LOCK". Or Lock to Door, depending on which way the triggering went. I'll probably even be able to get actual doors to appear or disappear without much more effort.