Page 1 of 1

How would I make this alias?

Posted: Wed Jul 18, 2018 4:19 am
by Vooku
Want to be able to type "dragX Y". X being a number 1-? and Y being a direction (n,s,e,w,u,d)

Example would be:

"drag3 n"

and have it return "drag 1.corpse drag 2.corpse drag 3.corpse n"

Thanks in advance!

Re: How would I make this alias?

Posted: Wed Jul 18, 2018 11:50 am
by Jor'Mox
Your pattern would look like this: ^drag(\d+) (\w+)

And the code would look like this:
Code: [show] | [select all] lua
local cmd = ""
for k = 1,matches[2] do
   cmd = string.format("%s drag %d.corpse",cmd, k)
end
cmd = cmd .. " " .. matches[3]
cmd = string.trim(cmd)
send(cmd)
The for loop should make all of the "drag #.corpse" parts and append them all together, and then you tack on the direction at the end. And given how it is set up, you still end up with a leading space, which you remove with the string.trim line.

Re: How would I make this alias?

Posted: Wed Jul 18, 2018 12:43 pm
by Vooku
Awesome. Works perfectly! Thanks:)