How would I make this alias?

Post Reply
Vooku
Posts: 70
Joined: Sun Aug 21, 2016 2:42 pm

How would I make this alias?

Post by Vooku » Wed Jul 18, 2018 4:19 am

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!

Jor'Mox
Posts: 1089
Joined: Wed Apr 03, 2013 2:19 am

Re: How would I make this alias?

Post by Jor'Mox » Wed Jul 18, 2018 11:50 am

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.

Vooku
Posts: 70
Joined: Sun Aug 21, 2016 2:42 pm

Re: How would I make this alias?

Post by Vooku » Wed Jul 18, 2018 12:43 pm

Awesome. Works perfectly! Thanks:)

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests