Problem with wildcards

Posted by Fjodor on Fri 17 Oct 2003 05:51 PM — 5 posts, 22,326 views.

Sweden #0
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.

Canada #1
Click regular expression and use this:

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

See the RegularExpressions.txt file in your MUSHclient directory for details of using regular expressions.
Canada #2
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).
USA #3
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.
Sweden #4
Thanks Magnum, now it works like I want it to :)