Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ VBscript ➜ A way to send directions that are the opposite of the exits shown?

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

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Weston   (28 posts)  Bio
Date Thu 19 May 2005 06:32 AM (UTC)
Message
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.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Thu 19 May 2005 07:28 AM (UTC)
Message
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)?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Weston   (28 posts)  Bio
Date Reply #2 on Thu 19 May 2005 01:39 PM (UTC)
Message
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?
Top

Posted by Weston   (28 posts)  Bio
Date Reply #3 on Sun 22 May 2005 05:01 AM (UTC)

Amended on Sun 22 May 2005 05:04 AM (UTC) by Weston

Message
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.
Top

Posted by Meerclar   USA  (733 posts)  Bio
Date Reply #4 on Sun 22 May 2005 10:16 AM (UTC)
Message
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.

Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #5 on Sun 22 May 2005 09:03 PM (UTC)

Amended on Sun 22 May 2005 09:06 PM (UTC) by Flannel

Message
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

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Weston   (28 posts)  Bio
Date Reply #6 on Mon 23 May 2005 09:48 PM (UTC)
Message
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.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


24,671 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.