Flexible offensive aliases

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Flexible offensive aliases

Post by naftali » Fri May 07, 2010 4:28 pm

the flexibility comes in when you have optional arguments for your alias, kinda. Lets say, for example, you have a variable called 'tar' set to 'naftali', and another one 'bdp' set to 'neck'. You then make an alias that looks like such.

pattern: ^str(?:| (\w+)(?:| (\w+)))$

explanation of the pattern: whenever you type in 'str', followed by either one or two words, the alias will fire. Anyway, the script:

target = matches[2] or tar
bodypart = matches[3] or bdp
send("strike " .. target .. " " .. bodypart)

the way this alias is set up, if you just enter 'str' then matches[2] and matches[3] will be nil. The cool thing about 'or' is that if the first part is nil it goes to the second part. So heres some examples of what this alias would do. Remember, for these 'tar' is 'naftali' and 'bdp' is 'neck'

str - strike naftali neck
str bob - strike bob neck
str bob foot - strike bob foot

that help?

Digital Ninja
Posts: 26
Joined: Mon Jun 07, 2010 1:43 am

Re: Flexible offensive aliases

Post by Digital Ninja » Fri Jun 11, 2010 1:57 am

Just curious, but what if you have a target that is say 2.monster
With the following set up, it does not allow the 2.monster, only fear monster...

Any ideas on how to allow dot?
Code: [show] | [select all] lua

ALIAS: Fear
Pattern: ^fear(\s(\w+))?$
Body: send("cast 'fear'" ..targ(matches[3] or t))

SCRIPT:
targ function:
function targ( t )
   if t == nil then
      return " " ..tar
   else
      return " " ..t
   end
end

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Flexible offensive aliases

Post by naftali » Fri Jun 11, 2010 4:37 pm

Code: [show] | [select all] lua
ALIAS: Fear
Pattern: ^fear(\s([\w\.]+))?$
Body: send("cast 'fear'" ..targ(matches[3] or t))

SCRIPT:
targ function:
function targ( t )
   if t == nil then
      return " " ..tar
   else
      return " " ..t
   end
end

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Flexible offensive aliases

Post by syrik » Sun Jun 27, 2010 5:28 am

ok, need something more basic, I copied and pasted the first flexible one in, but it still didn't work. Sorry :(

syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Flexible offensive aliases

Post by syrik » Sun Jun 27, 2010 2:52 pm

OK, got one of them to work!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest