| Message |
There is a bit of a discussion about this here:
http://www.gammon.com.au/forum/?bbsubject_id=3311
A fairly good way is to simply add this alias (I have amended the one in the above thread a bit to use Lua, as that is now the recommended script language):
<aliases>
<alias
match="^#(\d+) (.*?)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>Execute (EvaluateSpeedwalk ("%1 (%2)"))</send>
</alias>
</aliases>
See http://mushclient.com/pasting for how to add this into your world.
The alias above uses EvaluateSpeedwalk to do things repeatedly (as in, you can do 4n or 4(burp)).
However that one fails if you have a bracket in the thing you are trying to do (as that will confuse EvaluateSpeedwalk). The version below simply does a loop, so that might be better:
<aliases>
<alias
match="^#(\d+) (.*?)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
for i = 1, %1 do
Execute "%2"
end -- for loop
</send>
</alias>
</aliases>
All that does is take the number you supply, and do the command that many times.
Maybe it is wise to check the repeat count is not too small or too big, this is my final version:
<aliases>
<alias
match="^#(\d+) (.*?)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
if %1 < 1 then
ColourNote ("white", "red", "Too few repeats specified (%1)")
return
end -- if
if %1 > 50 then
ColourNote ("white", "red", "Too many repeats specified (%1)")
return
end -- if
for i = 1, %1 do
Execute "%2"
end -- for loop
</send>
</alias>
</aliases>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|