A way to send directions that are the opposite of the exits shown?

Posted by Weston on Thu 19 May 2005 06:32 AM — 7 posts, 31,714 views.

#0
I want to send a group of directions that are the opposite of the exit directions shown.

The exit directions look like this:

You see a single exit leading north.

...and for that one, I would want to send the remaining directions:

northeast
east
southeast
south
southwest
west
northwest
up
down
in
out



Another example:

You see exits leading north, northeast, east (closed door), southeast, south, and southwest.

I would want to send:

west
northwest
up
down
in
out



The exit line changes depending on the number of exits and if there are any doors.

You see a single exit leading northwest.
You see a single exit leading northwest (open door).
You see a single exit leading northwest (closed door).

You see exits leading north and northeast.

You see exits leading north (open door), northeast (open door), and east.
You see exits leading north, northeast, east, and southeast.
You see exits leading north, northeast, east (closed door), southeast, south, and southwest.
USA #1
Looks like the exits are always in the same order (what is that order?).

Should be simple enough to make an array with each direction, then loop through it and send what doesn't match (subtract the trigger match from the array of all of them, basically).

And, can each direction have a door (that's either open or closed)?
#2
The order of the exits is: north, northeast, east, southeast, south, southwest, west, northwest then up, down, in and out.

If there were three exits, for example: west, up and southwest. It would appear as southwest, west, and up.

And yes, any direction can have a door.



I have no idea how to create an array!
Uhm, is there any chance you could write something that I could use? Please?
#3
At first I tried to create one trigger for each possible combination of directions, but after three days I was only up to north, southeast, south and southwest.

Then I tried to do some kind of scripting, but the best I could do was:

<trigger
enabled="y"
ignore_case="y"
match="*You see exits leading *, *, and *.*"
send_to="12"
sequence="401"
>
<send>if %2 or %3 or %4 = north then
SendImmediate &quot;south&quot;
end if
if %2 or %3 or %4 = northeast then
SendImmediate &quot;southwest&quot;
end if
if %2 or %3 or %4 = east then
SendImmediate &quot;west&quot;
end if
if %2 or %3 or %4 = southeast then
SendImmediate &quot;northwest&quot;
end if
if %2 or %3 or %4 = south then
SendImmediate &quot;north&quot;
end if
if %2 or %3 or %4 = southwest then
SendImmediate &quot;northeast&quot;
end if
if %2 or %3 or %4 = west then
SendImmediate &quot;east&quot;
end if
if %2 or %3 or %4 = northwest then
SendImmediate &quot;southeast&quot;
end if
if %2 or %3 or %4 = up then
SendImmediate &quot;down&quot;
end if
if %2 or %3 or %4 = down then
SendImmediate &quot;up&quot;
end if
if %2 or %3 or %4 = out then
SendImmediate &quot;in&quot;
end if
</send>
</trigger>


One problem is that if the exits were north, east, and south. This thing sends south, west and north, not just west.

Another problem is the in direction. I had to remove it because it kept making error messages.
Amended on Sun 22 May 2005 05:04 AM by Weston
USA #4
For scripting, I'd probably go with a boolean value for each direction set to true, a check for exits in each direction to turn the value for that directions variable false and a return on the true values after the exits are checked. This avoids your issue of "north south west" returning "north south east", which is *logically* true based on the checks you are having performed.
USA #5
Your version won't work (well, for a number of reasons) but you also need to include quotes around your strings (and your wildcards).

Anyway, here's a quick and dirty little hack (it really is rather ugly) that works:
<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="^You see (?:a single )?exits? leading (.*)\.$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>dim i,j
dim yesDirs, noDirs
dim noArr, yesArr
noArr = array("north","northeast","east","southeast","south","southwest","west","northwest","up","down","in","out")
yesDirs = "%1"
yesDirs = Replace(yesDirs," (open door)","")
yesDirs = Replace(yesDirs," (closed door)","")
yesDirs = Replace(yesDirs," and",",")
yesDirs = Replace(yesDirs," ","")
yesDirs = Replace(yesDirs,",,",",")
yesArr = split(yesDirs,",")
for i = 0 to UBound(yesArr)
  for j = 0 to UBound(noArr)
    if yesArr(i) = noArr(j) then
      noArr(j) = ""
      exit for
    end if
  next
next
noDirs = ""
for i = 0 to UBound(noArr)
  if noArr(i) &lt;&gt; "" then
    if noDirs &lt;&gt; "" then
      noDirs = noDirs &amp; ","
    end if
    noDirs = noDirs &amp; noArr(i)

  end if
next
note noDirs</send>
  </trigger>
</triggers>


You'll almost certainly want to keep it as an array (although I suppose you could just split it again afterwards) but you'll need to keep that last bit of logic in whatever you use it with (provided you don't convert it from an array) because you need to screen out the empty strings.
You can even just replace the whole appending thing and just send from there (provided you do just want to send a bunch of directions), like this:
for i = 0 to UBound(noArr)
  if noArr(i) &lt;&gt; "" then
    send noArr(i)
  end if
next
Amended on Sun 22 May 2005 09:06 PM by Flannel
#6
IT WORKS!!! Hallelujah!

Thank-you very much Flannel!
You too Meerclar!

I can't believe this! It's so awesome, and it didn't need a thousand separate triggers and nearly 1MB of text.

I went with the:
for i = 0 to UBound(noArr)
if noArr(i) <> "" then
send noArr(i)
end if
next


The other one didn't work for me.