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 ➜ Problem with wildcards

Problem with wildcards

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


Posted by Fjodor   Sweden  (13 posts)  Bio
Date Fri 17 Oct 2003 05:51 PM (UTC)
Message
Ok, I've searched the entire forum and can't find the solution to this problem.
What I want to do is this.
I have a alias named "v * *"
And another alias named "v2 * * *"
To call a script looking like this :

sub VoiceLeave (thename, theoutput, thewildcards)
dim sInputted
dim sNum
dim sDir
sMob = thewildcards (1)
sNum = thewildcards (2)
sDir = thewildcards (3)
if sDir = "" then world.send ("voice " & sMob & " to leave " & sNum)
if sDir <> "" then world.sned ("voice " & sMob & " " & sNum & " to leave " & sDir)
end sub

This works like a charm, but my problem is that I only want to have ONE alias and not 2.
So if I type 'v spider east'
it should send 'voice spider to move east' this works
but I allso want to be able to type 'v spider 2 east'
and then it should send 'voice spider 2 to move east'
Like it is now I have to type 'v2 spider 2 east'
Any sugestion how I can solve this problem ?
I've tried with 2 aliases one named 'v * *' and one 'v * * *' but this didn't work as it trigged on the one with 2 wildcards when I had 3 in the command line.
Hope you understand what I'm trying to work out here.

Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #1 on Fri 17 Oct 2003 07:55 PM (UTC)
Message
Click regular expression and use this:

^v (.*?) (\w*)$

See the RegularExpressions.txt file in your MUSHclient directory for details of using regular expressions.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #2 on Fri 17 Oct 2003 08:02 PM (UTC)
Message
Oh, you won't need those IF statements either. TheWildcards(2) will always be the last word, and TheWildcards(1) will be all text between "v " and the last word (but not including the space before the last word).

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Shadowfyr   USA  (1,791 posts)  Bio
Date Reply #3 on Fri 17 Oct 2003 08:37 PM (UTC)
Message
Umm.. Maybe.. lol


<alias
  match="v /w+ (/d+ )?/w+"
  regexp="y"
  enabled="y"
  script="VoiceLeave">
</alias>

Then the script:

sub VoiceLeave(name, output, wilds)
  dim sMob, sOut, sNum, sDir
  sMob = wilds (1)
  sNum = rtrim(wilds (2)) ' To get rid of the extra space.
  sDir = wilds (3)
  sOut = ""
  if sNum <> "" then
    sOut = sMob & " " & sNum
  else
    sOut = sMob
  end if
  world.send ("voice " & sOut & " to leave " & sDir)
end sub


Hmm. Just noticed Magnum's posting, he must have finished his as I started mine. lol It would work as well, since all you need in the sub then is:

world.send ("voice " & wilds(1) & " to leave " & wilds(2))

which is admittedly simpler.
Top

Posted by Fjodor   Sweden  (13 posts)  Bio
Date Reply #4 on Fri 17 Oct 2003 08:46 PM (UTC)
Message
Thanks Magnum, now it works like I want it to :)
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.


17,983 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.