[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  A way to send directions that are the opposite of the exits shown?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

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] Refresh page


Posted by Weston   (28 posts)  [Biography] 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.
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] 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.
[Go to top] top

Posted by Weston   (28 posts)  [Biography] 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?
[Go to top] top

Posted by Weston   (28 posts)  [Biography] 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.
[Go to top] top

Posted by Meerclar   USA  (733 posts)  [Biography] 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
[Go to top] top

Posted by Flannel   USA  (1,230 posts)  [Biography] 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.
[Go to top] top

Posted by Weston   (28 posts)  [Biography] 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.
[Go to top] 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.


6,871 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]