|
JMinara Beginner
Joined: 05 Jul 2005 Posts: 14
|
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Nov 03, 2006 4:00 pm |
If you are asking about named parameters in triggers as is possible with aliases, then no it is not possible. You simply need to assign you pattern matches to the local variable you desire. For example
|
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Nov 03, 2006 5:49 pm |
Actually, named arguments in triggers *is* implemented. The syntax was mentioned in a thread a while ago in the forum, but hasn't been added to the help file. The syntax is:
($localvar:...)
For example, to capture a number and store it in the $hp local variable, you could have a trigger pattern like this:
Then in your trigger script, you can refer to $hp to retrieve this captured number.
Code: |
#trigger {($hp:%d)} {#SHOW $hp} |
This syntax was chosen because it's very similar to the named argument syntax in Perl regular expressions (where a ? is used instead of the $) |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Nov 03, 2006 7:09 pm |
Thanks for the correction Zugg... I vaguely remember seeing that thread. As a matter of fact I could use that syntax myself to speed up a few triggers. Now the next question is, is the format the same if you are doing regular expression patterns?
|
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Nov 03, 2006 8:34 pm |
Maybe. I haven't tested this with regular expression triggers. The named argument syntax is handled at trigger compile time, and not at runtime. So, the named arguments *should* be stripped from the pattern regardless of whether or not it has the regex option checked. So try it and let me know.
|
|
|
|
JMinara Beginner
Joined: 05 Jul 2005 Posts: 14
|
Posted: Sat Nov 04, 2006 7:30 am |
Zugg: You can only have one named variable in a trigger. If there's more than one, the trigger tosses an error and won't compile saying invalid local variables
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Sat Nov 04, 2006 5:48 pm |
Hmm, that's wierd. I've confirmed that problem and added it to the bug list. Don't know what happened...it *used* to work. Sigh.
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Mon Nov 13, 2006 3:13 pm |
Can this same syntax be used with #REGEX triggers? I'm having difficulty finding a solution that works. The parser tells me that the local variable is invalid.
Code: |
#REGEX {^($hp:\d+)h\, ($mp:\d+)m} {#say HP: $hp MP: $mp} "" {nocr|prompt} |
I tried (?hp:\d+) and (?$hp:\d+), too. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Nov 13, 2006 3:30 pm |
The bug with triggers not liking more than one named argument still isn't fixed, that might have something to do with your problem Larkin ;)
|
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Mon Nov 13, 2006 3:32 pm |
This problem is different. It's not even parsing the syntax to create the trigger. Using just one local variable still doesn't work with regex...
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 13, 2006 8:37 pm |
Unfortunately the syntax isn't supported with the #REGEX command itself. If you create a trigger in the settings editor and then mark it as a regular expression, then you can use the named arguments. So it's just a problem with the #REGEX command on the command line since it doesn't parse the pattern argument. The command line parser currently only understands the zMUD pattern syntax and doesn't have a parser for regular expressions on the command line, so regular expressions are just treated as literal strings. This prevents the named arguments from being recognized.
|
|
|
|
|
|