Room exit capturing.

by Geb

Back to Mechanic's Corner.

Geb2005-01-21 00:23:48
I've been trying to work on a means of capturing all of the exits in a room and then using that information in a button display. I want to be able to, as long as I can see, know exactly what exits are in the room once I walk into it. What I need to know is how may I go about triggering the basic information and then converting it into their corresponding buttons (I only want the buttons for the room's present exits to show).
Unknown2005-01-21 09:13:06
Before I start, this is really annoying to do tongue.gif. I haven't even bothered to do it on my client yet.

First, create the variables for each exit, whether they are separate (@North) or data record (@Exits.North), or otherwise just create an empty @Exits string list. I'll be explaining this as if you choose to do the first option.

Now create a trigger matching the line which there is no exits for the room, it's "You see no obvious exits here." or something similar. Make this trigger make all exits null, for example:
#VAR North 0;#VAR South 0 ... etc.................. (separate vars)
or
#VAR Exits.North 0;#VAR Exits.South 0 ... etc......... (db vars)
or
#VAR Exits {} .................. (string list)

Next, we'll do the single-exit line. Create a trigger along the lines of:
You see a single exit leading {north|south|west|up|down|northeast .. etc}.
Make it execute:
#FORALL {north|south... etc.} {#IF (%i = %1) {#VAR %proper( %i) 1} {#VAR %proper( %i) 0}} ........... (that's for separate variables)

Now... we'll create a trigger for multi-exits, except single-line ones only. Use something like this for the pattern:
You see exits leading( * and %w.)$
Now that will fire:
#FORALL {north|south... etc.} {#IF (%match( "%1", " "%i"{ |,|.}")) {#VAR %proper( %i) 1} {#VAR %proper( %i) 0}}

Finally, the multi-line exits trigger... The most annoying of all tongue.gif. This trigger will use conditions, but for the moment I will explain the base trigger. Make it have an ID, e.g.: "multi_exits". For its pattern:
You see exits leading *$
This trigger wont have any value; all it does it matches this line to fire the conditions.
Now make a condition for each exit thrice... yes, three times doh.gif.
For each exit condition, make this as the pattern:
exitname{ |,|.} ........... (there is a space in front)
^exitname{ |,|.} .......... (NO space in front)
exitname{ |.|,|}$ .......... (space in front)
For each of these conditions, make them do:
#VAR exitname 1 ............ (replacing exitname with the exit the cond. will fire on)
Make all these exit cond's have a type of "ReParse", and you don't need a value for that.
Now, create another condition matching:
and ............... (a space in front of AND behind it)
Which fires nothing. Make this conditions type to "Within Lines" with a value of 1 -- this will make it match within 1 line.

There, you're done! Although, I do extremely doubt that this will work perfectly, as I have just created that right here. It may need a little tweaking or more.

About condition types: this is the "trigger option" of each condition, and "ReParse" makes it fire again on the same line as the trigger above, while "Within Lines" makes the trigger end within x lines, where x is the "value" of the trigger option. You can edit the types in the "States" panel of the trigger editor, and they have a default of "Pattern". The value of them is in the column proceding it. Refer to the help on conditions for more help.

If you are still stuck and need help, just ask here in this thread. Also, post any mistakes you find in it.

Extra tips: add ^ to the beginning of each trigger pattern to match the beginning of the line, but if zMUD has problems processing lines on a new line under the prompt, then don't do this (don't do this with conditions at all, only the ones which already have it). Another thing you could do is to add the ansi colour code onto each trigger, at the beginning of each pattern (but after ^ if you have it). The default ANSI code for the exits line is %e
Unknown2005-01-23 01:26:35
Personally I use zmud and have huge self-made maps, so if you have something similar, one easier way of going about things is to just simply grab your exit information from the mapper (if the map is good enough). Not ideal of course because sometimes your mapper gets lost. Often happens to me when I'm running away from huge amounts of angry Mags/Death Marshals in Angkrag =D
Unknown2005-01-23 03:24:41
It would be better to put the exits into variables, if you wanted to use them for buttons and things.