The alias here (written in Lua) demonstrates how to write a targetting function that lets you select a word in the output window, and make that your target.
For instance, if you have a kobold attacking you, double-click the word kobold in the output window (to select it) and then type "target". You can speed things up by making a macro like Alt+T to be the word "target".
The alias finds the line, and start and end column of the selection (if any). If found, it applies a regular expression to the found text to make sure it passes its rules (ie. is a single word consisting of A-Z or 0-9).
If no word is found, it uses utils.inputbox to request the name of the target to be typed in (which you can cancel if you don't want to type it).
For instance, if you have a kobold attacking you, double-click the word kobold in the output window (to select it) and then type "target". You can speed things up by making a macro like Alt+T to be the word "target".
The alias finds the line, and start and end column of the selection (if any). If found, it applies a regular expression to the found text to make sure it passes its rules (ie. is a single word consisting of A-Z or 0-9).
If no word is found, it uses utils.inputbox to request the name of the target to be typed in (which you can cancel if you don't want to type it).
<aliases>
<alias
match="target"
enabled="y"
send_to="12"
sequence="100"
>
<send>
do
local target -- Lua variable to hold our target
-- find the selection range
local startline, endline, startcol, endcol =
GetSelectionStartLine (),
GetSelectionEndLine (),
GetSelectionStartColumn (),
GetSelectionEndColumn ()
-- if a single line selected, take that word
if startline > 0 and
endline == startline and
startcol > 0 and
endcol > 0 then
local word = string.sub (GetLineInfo (startline, 1), startcol, endcol - 1)
-- sanity check on word (in case whole line selected)
_, _, target = string.find (word, "^([A-Za-z0-9]+)$")
end
-- otherwise prompt for one
if not target then
target = utils.inputbox ("Enter the name of the desired target",
"Select target")
end -- if no target selected
-- echo new target name
if target then
ColourNote ("white", "blue", "Target now " .. target)
SetVariable ("target", target) -- copy into MUSHclient variable
end -- have a target
end -- do
</send>
</alias>
</aliases>