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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
jtown84
Novice


Joined: 09 Oct 2007
Posts: 36

PostPosted: Wed Apr 02, 2008 9:46 am   

Allowing * in {} triggers
 
is there an option for this?
_________________
Aardwolf
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Wed Apr 02, 2008 9:54 am   
 
As in allowing the character '*' rather than the pattern match *?
Sure, use ~*
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Apr 02, 2008 10:11 am   
 
If you mean allowing wildcards, then no. You need to use a regex instead.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
jtown84
Novice


Joined: 09 Oct 2007
Posts: 36

PostPosted: Wed Apr 02, 2008 10:17 am   
 
shake, I have a trigger
Code:
^{@BSMessages}$

the Var BSMessages is a String list
Code:
You lunge at * with *|You stab at * with *|You try to crush * with *|You flail at * with *|You attempt to hit * over the head with *|You try to gash * with *|You thrust * at *|You swing hard at * with *|You attempt to bury * deep into * back

Whats the best way to get that to work.. note the * are multiple words that change.
_________________
Aardwolf
Reply with quote
jtown84
Novice


Joined: 09 Oct 2007
Posts: 36

PostPosted: Wed Apr 02, 2008 10:20 am   
 
Fang Xianfu wrote:
If you mean allowing wildcards, then no. You need to use a regex instead.

bleh:P I dont know regex
I thought there might be a way since you could in zMud. :P
_________________
Aardwolf
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Apr 02, 2008 10:34 am   
 
Nope, but changing that particular pattern will be easy - just change * to .* and {} to () and it should work fine. You could even just paste your pattern into a trigger and click the "Convert to Regex" button.

I'm sure someone's going to mention how slow that'll be, so I'll pre-empt them - using lots of .*s (and *s in zScript patterns, for that matter) like that will be very slow to match and to fail to match. If you care about that, take the time to read through some regex guides and use some of the more specific wildcards to speed up the match. You could also use more-specific zScript wildcards and then use Convert to Regex if you want.

Also, if you're not going to be using #sub, you don't need a * at the end of the line. I'll assume that you are using #sub, but if you're not, you can get rid of them and remove the end-of-line anchor.

I do wonder why the option from zMUD hasn't been carried over, though. I never had any problems with it, so perhaps it's just an oversight.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Wed Apr 02, 2008 1:36 pm   
 
have you considered a multiple annonymous stringlist trigger?

#TR{{you stabe at|you try to crush|you attempt to hit|ect} * {with|deep into|ect}}
_________________
Discord: Shalimarwildcat
Reply with quote
JQuilici
Adept


Joined: 21 Sep 2005
Posts: 250
Location: Austin, TX

PostPosted: Wed Apr 02, 2008 4:55 pm   
 
If BSMessages is exactly as you say, there may not be a reason to use any wildcards at all - you're not saving the results of the match anyway. If you don't HAVE to check past the first * to tell whether you want to match the string, then don't bother.

Thus, you could just use a pattern like
Code:
^You {@BSMessages}
with BSMessages having the value
Code:
lunge at|stab at|try to crush|flail at|attempt to hit|try to gash|thrust|swing hard at|attempt to bury


Faster yet would be to skip BSMessages and use a single regex, in which you rearrange the strings to group common substrings and use atomic groups to speed up rejection of non-matching lines:
Code:
^You (?>try to (?:crush|gash)|attempt to (?:hit|bury)|(?>lunge|stab|flail|swing hard) at|thrust)

That will match all of the same lines, with no wildcards, and should be somewhat faster.

Note that both of these patterns would also match some additional lines that the original would not (e.g. 'You attempt to hit yourself' would fail in the original, because there's no 'over the head with' later in the line), so do a sanity check to see if any such lines would cause a problem.

Also note that I wrote those patterns off the top of my head, so I haven't tested them extensively. YMMV.
_________________
Come visit Mozart Mud...and tell an imm that Aerith sent you!
Reply with quote
jtown84
Novice


Joined: 09 Oct 2007
Posts: 36

PostPosted: Wed Apr 02, 2008 6:31 pm   
 
This is what i did last night
Its not what i wanted to do because now i #gag and #say, vs just subbing it.
But it works
Thanks for all the help
Code:
^{You lunge at|You stab at|You try to crush|You flail at|You attempt to hit|You try to gash|You thrust|You swing hard at|You attempt to bury}
_________________
Aardwolf
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri Apr 04, 2008 12:38 am   
 
If you want to sub it just do like JQ did above.

Code:
^You (?>try to (?:crush|gash)|attempt to (?:hit|bury)|(?>lunge|stab|flail|swing hard)|thrust) [^.]*\.$
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Apr 04, 2008 12:48 am   
 
Er... except [^.] is pretty pointless since it's not going to match anything :S
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Apr 04, 2008 1:56 am   
 
Inside of a class the period is treated at a normal character. The rules for regex classes are somewhat convoluted, the only character that maintains the exact same meaning, as outside the class construct, is the backslash. [^.]* will properly match all characters that are not a period.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Fri Apr 04, 2008 2:40 am   
 
Right, the negated character class will match everything from from the atomic group to the end of the line period that isn't a "period". The difference is negated character class doesn't backtrack at all and is faster. Sure you can use ".*" just as well, but even that still backtracks once. I just prefer using the negated character class in certain instances.

http://www.regular-expressions.info/repeat.html
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Apr 04, 2008 10:25 am   
 
Ohhh, yeah. I'd forgotten that - I was remembering how \w and whatnot remained the same.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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