[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]  General
. . -> [Subject]  How to Match 'Directions, south west northeast southeast' ?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

How to Match 'Directions, south west northeast southeast' ?

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


Posted by Karl_Newbie   USA  (23 posts)  [Biography] bio
Date Sun 26 Sep 2004 08:39 AM (UTC)

Amended on Sun 26 Sep 2004 02:36 PM (UTC) by Karl_Newbie

Message
How do I match with a trigger the exits on my mud?
I want to capture the exit so I can use it as a wild card in a trigger or a variable.

I always see a line like the ones below.


Directions, south west northeast southeast

Directions, north south down east west

Directions, north south up

Directions, south up north

Directions, southwest west northwest in up

Directions are always a compass direction never a room name.
They always have two spaces after them, even the last one.

One problem is the mud does not list the directions in the same order even in rooms with similar directions.
Another is they can even spread across two lines if there are many directions.



I think the trigger would have to start like:

^Directions, (.*?)$

:)

But how do I set it so that there is a wildcard for every possible exit? Some rooms have 1 and others can have up to 10.

I just want a random auto walk trigger that doesn't send invalid directions to the mud.
Sort of like
randomize
social = Int( (n= number of directions*rnd)
if social=0 then
World.Send "%1"
elseif social=1 then
World.Send "%2"
elseif social=2 then
World.Send "%3"
etc
end if

I think would work

or using variables tho that would be more complicated and pointless I'd imagine?


randomize
social = Int(3*rnd)
if social=0 then
World.Send "getvariable("direction1")
elseif social=1 then
World.Send "getvariable("direction2")
elseif social=2 then
World.Send "getvariable("direction3")"
etc
end if


It's the matching trigger I have trouble with.
[Go to top] top

Posted by Nick Gammon   Australia  (21,381 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 26 Sep 2004 10:06 PM (UTC)
Message
It will be hard to make a trigger that matches a variable number of directions and make each one a wildcard, although it could be done.

What would be easy enough to simply use your trigger and then use "split" to break the text into multiple words.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Karl_Newbie   USA  (23 posts)  [Biography] bio
Date Reply #2 on Tue 28 Sep 2004 10:45 PM (UTC)

Amended on Wed 29 Sep 2004 01:49 AM (UTC) by Karl_Newbie

Message
Aso, thanks. I tried something like this with the split.

Match - ^Directions, (.*?)$

send

Dim Exitstring, ExitArray

ExitString = "%1"

ExitArray = Split(ExitString, " ", -1, 1)

randomize
social = Int(4*rnd)
if social=0 then
DoAfter 2, ExitArray(0)
elseif social=1 then
DoAfter 4, ExitArray(1)
elseif social=2 then
DoAfter 1, ExitArray(2)
elseif social=3 then
DoAfter 3, ExitArray(3)
[etc)
end if

But no I can't figure out what I'm doing wrong here. In rooms without enough directions for the randomize bit I get the 'nostring number' error.
And it still seems to only send the first exit.
Can you please help me along?


[Go to top] top

Posted by Nick Gammon   Australia  (21,381 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 29 Sep 2004 11:42 PM (UTC)
Message
Your problem is that the rnd*4 is returning a number assuming 4 exits. Try this, it is simpler:


<triggers>
  <trigger
   custom_colour="2"
   enabled="y"
   match="^Directions, (.*?)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>ExitArray = Split ("%1", " ")
DoAfter 2, ExitArray (Rnd * UBound (ExitArray))

</send>
  </trigger>
</triggers>



Using UBound, it finds the actual number of matching exits, and generates an appropriate random number.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Poromenos   Greece  (1,037 posts)  [Biography] bio
Date Reply #4 on Fri 01 Oct 2004 10:13 AM (UTC)
Message
Actually that's ExitArray(Int(Rnd*(Ubound(ExitArray) + 1))) as the manual suggest, otherwise it will give decimal numbers in the range 0-3.

Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it!
[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.


3,611 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]