Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
adamwalker
Apprentice


Joined: 12 Mar 2005
Posts: 195

PostPosted: 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?
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Fri Mar 31, 2006 2:38 pm   
 
http://forums.zuggsoft.com/phpbb/viewtopic.php?t=19812&highlight=regex+trigger+better

Seems that REGEX wins.
So if you know regex just write in that and it should same the time for zmud to convert.
But once converted it stays converted until a shutdown/restart, then it's back to a regular #trig.
Unsure if it converts it ONLY on the 1st actual use or on the startup tho.
_________________
http://www.Aardwolf.com
Reply with quote
adamwalker
Apprentice


Joined: 12 Mar 2005
Posts: 195

PostPosted: 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:)
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: 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!
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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.
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: 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
_________________
http://www.Aardwolf.com
Reply with quote
adamwalker
Apprentice


Joined: 12 Mar 2005
Posts: 195

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net