Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ Alias which adds aliases
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Sat 08 Apr 2006 12:37 AM (UTC) |
Message
| This is further to a forum post about how to make an alias "like Tintin".
If you add this alias to your world, you can type something like:
#alias {h} {cast 'cure light'}
What this will do is create another alias, which matches on "h" and sends 'cure light'.
However it also allows for an optional player name, eg. "h nick", and then it sends "cast 'cure light' nick".
<aliases>
<alias
match="^\#alias \{(?P<match>[A-Za-z]+)\} \{(?P<send>.+)\}$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>do
local result =
AddAlias ("%<match>", "^%<match>(?P<target> [A-Za-z]{1,}){0,1}$",
"%<send>%%<target>",
alias_flag.Enabled +
alias_flag.RegularExpression +
alias_flag.Replace,
"")
if result ~= error_code.eOK then
ColourNote ("white", "red", error_desc [result])
else
ColourNote ("white", "green",
"Alias '%<match>' added which sends '%<send>'")
end -- if
end -- do</send>
</alias>
</aliases>
The alias is created with the same name as the matching string (eg. an alias "h" will be named "h") so that you can easily replace an existing one, in case you change what "h" is going to send.
This alias is scripted in Lua, you would need to enable scripting and set the script language to Lua. If you are using VBscript or some other language the alias will be the same, and you need to rework the script syntax slightly. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Azoroth
(31 posts) Bio
|
Date
| Reply #1 on Wed 18 Jun 2008 11:32 PM (UTC) |
Message
| So I was using this alias to add a bunch of aliases that use command stacking within them. I'll give you a example of what I was adding using the alias you created above (note that I modified just the name of your alias which was #alias to #ALIAS for my own personal preference)
#ALIAS {blinloth} {linw;wlinmid;wmidpel;wpelosg;wosgroi;wroimid;wmidloth;wloth}
This alias would add fine, which was great. Each of those commands linw, wlinmid,wmidpel etc each contain their own set of commands. After adding the alias blinloth with the alias you created above and then typing it into the command line with command stacking enabled and the prefix set to ;
all I was getting sent to the output was linw;wlinmid;wmidpel;wpelosg;wosgroi;wroimid;wmidloth;wloth without each of the commands contained within those aliases to fire off. Is it even possible to do what I'm trying to do using this alias you created or will I have to go ahead and manually add them all? If you're having a hard time understanding exactly what I'm trying to do, I'll sit down and try to find another way to explain it if I do get any replies at all. Thanks as always! | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #2 on Thu 19 Jun 2008 12:47 AM (UTC) |
Message
| All you need to do is amend the alias to "send to execute", which makes the individual alias items be re-evaluated by the MUSHclient command processor. Like this:
<aliases>
<alias
match="^\#alias \{(?P<match>[A-Za-z]+)\} \{(?P<send>.+)\}$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>do
local result =
AddAlias ("%<match>", "^%<match>(?P<target> [A-Za-z]{1,}){0,1}$",
"%<send>%%<target>",
alias_flag.Enabled +
alias_flag.RegularExpression +
alias_flag.Replace,
"")
if result ~= error_code.eOK then
ColourNote ("white", "red", error_desc [result])
else
ColourNote ("white", "green",
"Alias '%<match>' added which sends '%<send>'")
SetAliasOption ("%<match>", "send_to", "10")
end -- if
end -- do</send>
</alias>
</aliases>
However I notice when trying it, that whilst the above works, if you use an argument it gets tacked onto the end, eg.
blinloth nick
--> sends:
linw
wlinmid
wmidpel
wpelosg
wosgroi
wroimid
wmidloth
wloth nick
See what I mean? The "nick" is only on the last one. However if you just do blinloth on its own it will be OK.
You could work around that, but I am just pointing it out, as what the current behaviour will be. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Mastarck
Poland (2 posts) Bio
|
Date
| Reply #3 on Thu 19 Jun 2008 01:36 PM (UTC) |
Message
| i have accelerator to firing alias to firing specjals
in tavern to sit down, entering ships, opening gates, and so on...
var SPEC1 contains string to output (filled by triggers)
and should be cleared after firing (SPEC1 = "")
<alias
name="specjal1"
match="^func1$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>SendSpecial(SPEC1,false,true,true,true)
SPEC1 = ""
</send>
</alias>
I cant use aliases as SPEC1, because they are sended directly to mud (can't send_to_execute, because i have to clear SPEC1)
how can use aliases in this alias? | Top |
|
Posted by
| Nick Gammon
Australia (23,046 posts) Bio
Forum Administrator |
Date
| Reply #4 on Thu 19 Jun 2008 05:55 PM (UTC) Amended on Thu 19 Jun 2008 05:56 PM (UTC) by Nick Gammon
|
Message
| Use Execute which evaluates aliases.
eg.
Execute (SPEC1) -- execute as command (processes aliases)
WriteLog (SPEC1) -- optional - log the line (but the alias might log it anyway)
SPEC1 = ""
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
19,310 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top