(Edit) Would like to share my late experience.
Not really something difficult but quiet useful.
Usually just after you get your MUSH client on your PC, you throw your aliases in bulk, careless, with the only aim to start playing.
After a while you have the Alias windows in such a mess.
Look at mine.
I had:
kka - cast 'protection from acid'
kkab - cast 'protection acid breath'
kkc
kkcb
kke
kkeb
kken
...
kkf - cast 'protection from fire'
I had NINE! All perfectly equal but for the string in the casting.
oh, yes, it works. Works well, But you guess.. even if MUSH is really fast, you can bet having thousands of alias (even though anyone is quiet simple) not different having few better organized with a little of scripting.
So..
What we have...
All the aliases start with kk followed by one or two letters (not any number).
Why don't use the Regular Expression Power even in the alisases?
So i checked the Regular Experssion box and i put:
i changed the ' Send To ' putting Script and i also checked " Omit from output "
' \w ' means a single "word" character; the {1,2} is the quantifier that specify minimum 1, maximum 2.
In the code window i wrote:
local prot = {
a = "from acid'",
ab = "acid breath'",
c = "from cold'",
cb = "frost breath'",
f = "from fire'",
fb = "fire breath'",
e = "from electricity'",
eb = "electric breath'",
en = "from energy'",
} -- end of prot
local P = prot ["%1"]
if P ~= nil then
print ("cast 'protection " .. P)
Send ("cast 'protection " .. P)
end -- if
Useless to say it works very well and it's very fast.
note the "%1" --> %1 inside the quotation marks
Is it all?
As a cleric named Eldanoth i have several cure spells.
my cure spells aliases were:
h1 - cast 'minor heal'
h2 - cast 'heal'
h3 - cast 'healing'
so when i want to cure my companion i write:
h2 *companion name* - more or less: cast "heal" %1
At a point i liked the idea that:
1) if i don't put the name %1 the spell is cast on me
2) if i'm in a group engaged in combat, not putting any %1 after h2 will heal the Tank . That's very useful! Over all when you battle MOB that Switch from one target to another! Means you cure Always the Right target keeping typing simply h3 or whatever.
3) ..but if i'm the tank, send also a "Stand" command (even though i have a "Stand" trigger that works well in 90% of the cases, you really don't know)
4) if, for any reason and in any of the above situations i define "%1" , then he is healed instead
The Outcome is that i simply write h3 (or h2 or h1) and the spell is cast onto the target specified by the condition i find myself.
so we have h followed by one digit.
the Regular Expression to define the Alias is:
As you can see i put an optional space in the beginning
It come in hand when you put the alias just after a ; to make a whole string of command, separated by a space. (...)
Before to post the code i have to explain that the MUD i'm playing with is called " Tempora Sanguinis ".
In the variables page, withing the mxp variables there is one very interesting:
- mxp_tstank .
The value is:
- "*" when there is NO tank
- "name of the tank" when someone is tanking
Remember you have to check the box Expand variables to let the variable be read.
So...
local Cura = {"minor heal' ", "heal' ", "healing' "}
local C = Cura[%1]
if C ~= nil then
if "%2" == "" and "@mxp_tstank" == "*" then
Send("cast '" .. C .. "eldanoth")
elseif "%2" ~= "" then
Send ("cast '" .. C .. "%2")
else
if "@mxp_tstank" == "Eldanoth" then Send ("stand") end
Send ("cast '" .. C .. "@mxp_tstank")
print (" - - - - - Tank route - - - - -")
end -- if
end -- if
in this case please pay attention at local variable "C"
local C = [%1]
So %1 - WITHOUT - quotation marks because the value got from the first wildcard let you access the array (oops, table) specifying the element you want to pick.
And that's all.
I could've taken the whole range of Cure spells, ranging from "Cure light wounds" to the top, simply increasing the members of the table.
I dedice to share after reading the interesting post on how to delete the last word.
Clever!
ANY FURTHER SUGGESTIONS? --- please, feel free to comment add / criticize --- |