|
adamwalker Apprentice
Joined: 12 Mar 2005 Posts: 195
|
Posted: Fri Mar 31, 2006 1:13 pm
REGEX or TRIG? |
Can anyone tell me which is better to use...
#REGEX {You touch the tree of life tattoo\.$} {blah blah blah}
or
#TRIGGER {You touch the tree of life tattoo.$} { blah blah blah}
is there actually a difference? |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
|
|
|
adamwalker Apprentice
Joined: 12 Mar 2005 Posts: 195
|
Posted: Fri Mar 31, 2006 3:25 pm cool |
never knew that. i guess i better get working... i have about 40 thousand words to convert to regex. heh.
ill wait till cmud is out cos im sure there will be a ton of enhancements i would like to make at the same time
thanks for the info:) |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Mar 31, 2006 5:01 pm |
Well based on that is using #REGEX the same as converting your #TRIGGER to a perl expression? Can you use #COND with #REGEX? The documentation doesn't suggest that you can.
|
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Mar 31, 2006 5:12 pm |
All zMUD triggers are converted to regular expressions these days, so most anything you can do with a normal pattern you can do with a regular expression. When using a #COND you can specify regex in the options, or in the GUI you can select Regular Expression from the pull-down menu of trigger types.
However, there are a couple of things that only work with normal patterns: The &varname syntax, for example, which matches a subpattern and automatically stores the value into the @varname variable, only works with normal zMUD syntax. The pattern is still converted to a RegExp, but zMUD adds some hooks to capture the pattern and store the variables automatically.
In general, my recommendation is to *not* use #REGEX unless you absolutely have to. Here are the reasons:
1) Regular expression syntax is *much* more complicated than zMUD trigger syntax in most cases, and will make your triggers and scripts harder to understand and debug (unless you are a RegExp guru).
2) Sharing your scripts with others will be harder since other people might not be a RegExp expert and won't understand your scripts.
3) You will loose any benefit of future optimizations. #REGEX passes stuff directly to the internal Perl regular expression engine without any conversion or optimization. So if anything gets added to the zMUD trigger language at a later time, you won't be using it.
4) While it's easy to convert a zMUD trigger to a regular expression, this is a one-way conversion. There is no way to convert a RegExp back to a zMUD trigger at a later date.
5) The conversion from zMUD trigger syntax to RegExp syntax is very quick and is only done once the first time the trigger is executed. This is like compiling a script (and in CMUD, it's treated the same as the compile step). Since your triggers run over and over again, the overhead of converting to regular expressions is very small. So the post that Vitae linked is a bit misleading.
So, think about this before converting your triggers. |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Fri Mar 31, 2006 7:55 pm |
Well, at least i was right when i said:
But once converted it stays converted until a shutdown/restart, then it's back to a regular #trig.
...i think..heheh |
|
|
|
adamwalker Apprentice
Joined: 12 Mar 2005 Posts: 195
|
Posted: Sat Apr 01, 2006 5:11 am |
wow! thanks for such a comprehensive reply.
Would I notice a speed difference on a big system? (40k words++)
im just being a bit anal. hehehe |
|
|
|
|
|