keybind issues

Post Reply
fauxpaws
Posts: 1
Joined: Sun May 23, 2010 9:31 pm

keybind issues

Post by fauxpaws »

Code: Select all


ALIAS
pattern: ^t (\w+)$
script:
target = matches[2]
echo ("Your target is now " .. target)

KEYBIND:(no command):no modifiers + F1
script:
send ("cast stormlance " .. target)
echo ("casting stormlance")

this isnt working - it's almost like the program isnt capturing the keystroke - or do i need a command line to force it to process the script?

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: keybind issues

Post by Vadi »

Is it enabled?

Fo-Rum
Posts: 32
Joined: Fri May 21, 2010 7:38 pm

Re: keybind issues

Post by Fo-Rum »

Keybindings aren't enabled by default, so like Vadi suggested with his question, it might not be enabled.

Also, instead of using \w+ for your match, you're probably better off using .* instead. Sometimes you want to target by just their ID (which is a number and not a word). Granted, most of the time, that isn't needed, but best to have it ready.

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: keybind issues

Post by Iocun »

\w matches numbers as well as letters, so it should be fine.

Fo-Rum
Posts: 32
Joined: Fri May 21, 2010 7:38 pm

Re: keybind issues

Post by Fo-Rum »

Iocun wrote:\w matches numbers as well as letters, so it should be fine.
Yeah, the single letter W makes me think of "word", which to me excludes digits. You're right. The definition for w says alphanumeric characters.

Still, it doesn't capture everything he might want to target, such as names with hyphens and other non-alphanumeric. Although, for IRE games this probably isn't an issue since you can usually target with various names for one target anyway. Cave-fisher for example, I believe you can target with just "fisher". Either way, I still suggest using .* to match any possible target name you might need to use.

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

Re: keybind issues

Post by naftali »

Your point is a good one. I would move towards using something like [\w\-_']+ since that still excludes spaces and other characters never found in names, like % or @

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: keybind issues

Post by Iocun »

I don't think there's any reason to escape the "-" if it's used in this particular position in the character class (but I can see why you'd want to do it for the sake of clarity). Underscores are already being matched by \w so there's no need for that either.

[\w-']+ should work. Of course, unless you have any reason to type "t whatever" in other cases you might as well go with Fo-Rum's simpler ".*" or ".+".

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

Re: keybind issues

Post by naftali »

can't '-' be used in character classes to specify ranges, though? Such as in [A-Za-z]

Iocun
Posts: 174
Joined: Wed Dec 02, 2009 1:45 am

Re: keybind issues

Post by Iocun »

Yeah, but if that's not applicable (since \w-' isn't an actual range), "-" just stays "-".

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

Re: keybind issues

Post by naftali »

Iocun wrote:Yeah, but if that's not applicable (since \w-' isn't an actual range), "-" just stays "-".
nice, didn't know it could make that distinction.

Post Reply