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
nilse75
Newbie


Joined: 23 Nov 2010
Posts: 5

PostPosted: Tue Dec 07, 2010 1:12 pm   

Help with trigger, two cases
 
On the MUD I'm playing you can assign labels to players that can contain any length of letters.

I'm writing a trigger that matches two cases, both with and without labels.
These are the texts that I want to be able to match.

Code:
Player has arrived from the south.
Player (leader) has arrived from the south.


The following trigger works OK:

Code:
<trigger priority="9280" case="true" id="928">
  <pattern>^(%w){ ~(leader~)|} has arrived from the *.$</pattern>
  <value>#Show {Match! player=%1}</value>
</trigger>


However, here I have specified the label as "leader" and if I want to use different labels (I want to match all)
it doesn't work. When I replace leader with * in the following example it doesn't work.

Code:
<trigger priority="9280" case="true" id="928">
  <pattern>^(%w){ ~(*~)|} has arrived from the *.$</pattern>
  <value>#Show {Match! player=%1}</value>
</trigger>


Any ideas why? Maybe there is a better way of writing this trigger?
Reply with quote
Alocer
Newbie


Joined: 01 Dec 2010
Posts: 7

PostPosted: Tue Dec 07, 2010 2:42 pm   
 
This Regex should work for you:
Code:
^(\w+)\s(?:\(.+\)\s)?has arrived from the


Make sure you check the box for Regular Expression

If you know the types of characters you might have for the label, it's best to not use the ".+" pattern (the dot character matches almost everything). Such as if you know you'll just have alpha-numeric characters and spaces, you can replace ".+" with "[\w\s]+"
Reply with quote
nilse75
Newbie


Joined: 23 Nov 2010
Posts: 5

PostPosted: Tue Dec 07, 2010 3:59 pm   
 
Thanks. I figured it would be best to use regular expressions to solve this. Since I'm really bad at writing them I try to avoid them. Just curious, is it not possible to use * inside {alternative 1|alternative 2} in zscript because that is what's not working for me.
Reply with quote
Tech
GURU


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

PostPosted: Tue Dec 07, 2010 5:18 pm   
 
No, you can't use wildcards in expression lists.
_________________
Asati di tempari!
Reply with quote
Zugg
MASTER


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

PostPosted: Tue Dec 07, 2010 6:18 pm   
 
Actually, there is an option for this. Look in the Scripting page of the Preferences and you'll see an option called "Allow wildcards within {} trigger patterns". Try turning that on. Just keep in mind that putting wildcards within {} lists will slow the triggers down, so it's best to avoid them when possible.
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