Re: Flexible offensive aliases
Posted: 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?
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?