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
➜ General
➜ Aliases
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Fluxo
(2 posts) Bio
|
Date
| Fri 09 May 2003 09:31 AM (UTC) |
Message
| Hello.
I want to get an alias working both with and without an argument.
If I have "blah *" as my alias, then typing blah whoever works fine. But of course blah on it's own doesn't.
If I have "blah*" instead, then typing blah on it's own works fine, but blah whoever ends up with an extra space between the command and the whoever, as the space is counted as part of the argument. This causes problems on my mud.
Is there any way I can make an alias that will work both with and without an argument passed to it? Essentially it's for stuff like heal aliases, where I want to 'cast heal person' if there's an argument, or just 'cast heal' if there isn't (which would heal myself). | Top |
|
Posted by
| Vaejor
(120 posts) Bio
|
Date
| Reply #1 on Fri 09 May 2003 12:40 PM (UTC) |
Message
| This should work:
<aliases>
<alias
name="heal_alias"
match="^blah( (?:.+))?$"
enabled="y"
regexp="y"
>
<send>cast heal%1</send>
</alias>
</aliases>
The outer () has a ? on the end to make it optional.
The inner () has ?: at first, which makes it to where it doesn't remember the information, but still checks for it. The . means to check for any character, and the + means that the previous item has to match 1 or more times.
Since the outer () is storing into %1, and it contains a space in it already, the final output you send to the mud should not have a space before the %1(since it's inside this variable). | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #2 on Fri 09 May 2003 12:53 PM (UTC) |
Message
| This can be accomplished by using a regular expression. This is a special type of syntax for building aliases and triggers. It is explained fully in a text file within your MUSHclient directory, called RegularExpressions.txt .
Here is a tidbit from one of my plugins, which uses an alias with an optional argument:
<aliases>
<alias
name="EQ_Display_Help"
script="EQ_Help"
match="^eqhelp(?:[ ]+(.*))?$"
enabled="y"
regexp="y"
ignore_case="y"
>
</alias>
</aliases>
<script>
<![CDATA[
Sub EQ_Help (AliasName, AliasLine, arrWildcards)
Dim HelpArgument
HelpArgument = Trim(LCase(ArrWildcards(1)))
Select Case HelpArgument
Case "eqt"
EQ_Help_eqt "EQ_Help", AliasLine, arrWildcards
Case "eqset"
EQ_Help_eqset "EQ_Help", AliasLine, arrWildcards
Case "eqxa"
EQ_Help_eqxa "EQ_Help", AliasLine, arrWildcards
Case "eqxr"
EQ_Help_eqxr "EQ_Help", AliasLine, arrWildcards
Case "eqlist"
EQ_Help_eqlist "EQ_Help", AliasLine, arrWildcards
Case "eqg"
EQ_Help_eqg "EQ_Help", AliasLine, arrWildcards
Case "eqd"
EQ_Help_eqd "EQ_Help", AliasLine, arrWildcards
Case "eqon"
EQ_Help_eqon "EQ_Help", AliasLine, arrWildcards
Case "eqoff"
EQ_Help_eqoff "EQ_Help", AliasLine, arrWildcards
Case "eqfix"
EQ_Help_eqfix "EQ_Help", AliasLine, arrWildcards
Case "eqlvl"
EQ_Help_eqlvl "EQ_Help", AliasLine, arrWildcards
Case "eqsw"
EQ_Help_eqsw "EQ_Help", AliasLine, arrWildcards
Case "eqcolour"
EQ_Help_eqcolour "EQ_Help", AliasLine, arrWildcards
Case Else
EQ_Help_General "EQ_Help", AliasLine, arrWildcards
End Select
End Sub
]]>
</script>
In my alias, the ?:[ ]+ part of the expression is what catches the space. The ?: means match on this, but don't return it as part of the result. The [ ]+ part means match on 1 or more spaces (since there is only a space between the brackets). |
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 #3 on Fri 09 May 2003 12:59 PM (UTC) |
Message
| Heh, I took my time replying while playing on my mud. I think both regular expressions should work (mine and Vaejor's). |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | 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.
16,294 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top