About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
geosmith
Wanderer


Joined: 23 Apr 2005
Posts: 57

PostPosted: Sat Aug 13, 2005 1:08 pm   

Sorry, -another- trigger question
 
Again, I feel like I'm missing something obvious here, but I'm trying to create a trigger to capture the names from a line of text and add them to a string list variable.

The names I'm trying to capture are in the following format...

Name, Name, Name, Name, Name, Name, Name
, Name, Name, Name, Name, Name, Name, Name,

I've tried setting the following trigger:

#TRIG {(%w),} {#ADDI variable %1}

The problem is, that only seems to acquire the very first name from each line, rather than all of them. Is there something I'm overlooking?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Aug 13, 2005 4:57 pm   
 
Triggers--using built-in zmud wildcards at least--only process the line one time rather than recursively like some regular expressions do. You probably will have to look at regex or use *, the latter at least requiring you to do the parsing yourself in trigger code (it's fairly easy.)
_________________
EDIT: I didn't like my old signature
Reply with quote
geosmith
Wanderer


Joined: 23 Apr 2005
Posts: 57

PostPosted: Sat Aug 13, 2005 6:40 pm   
 
Okay, Regex is something new to me, and though I've had a look over it I'm still struggling to achieve the desired result.

I created a trigger with the expression (\a+) and the value #CW red, then tested it with the line "Bob, Steve". Perfect, I thought - both names appeared in red as intended.

However, when I tried replacing the #CW red value with #ADDI variable %1, and tested the whole thing again, the only name to be added to the variable was the first on the line, so it looks like I'm no better off than when I started.

Surely there has to be a way to have zMUD add multiple examples of a trigger pattern to a variable without resorting to something as tedious as..
#TRIG {(%w), (%w), (%w), (%w),} {#addi variable %1;#addi variable %2;#addi variable %3;#addi variable %4}...?

Edit:

Incidentally, the script shown here - http://forums.zuggsoft.com/phpbb/viewtopic.php?t=17203 - is pretty similar to what I'm trying to achieve, though it looks like the author couldn't find a simpler way to capture multiple names from a single line either.

Edit:

Found the following at http://www.perldoc.com/perl5.8.4/pod/perlretut.html.

The modifier //g stands for global matching and allows the matching operator to match within a string as many times as possible...
... But what if we had an indeterminate number of words? This is the sort of task //g was made for. To extract all words, form the simple regexp (\w+) and loop over all matches with /(\w+)/g


Now I'll be honest, I know nothing at all about Perl, so making anything useable out of that is beyond me, but is there any way it can be applied to the problem I'm having?
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Sun Aug 14, 2005 2:59 am   
 
What can you use to predict the line:
Name, Name, Name, Name, Name, Name, Name
, Name, Name, Name, Name, Name, Name, Name,


Once you can grab the entire line all you would need to do is:
#VAR variable %replace(%line,", ","|")
etc
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Aug 14, 2005 11:04 am   
 
Actual mud output would be helpful. Include some lines before and after, as well any command you use to initiate the 'name, name, etc.' response from the mud. Quite often it is better to trigger on something other then what your looking for, because it has a consistent output. So far in your example you have a line that might end with a comma or not, and a line that might start with a comma or not. It just isn't specific enough.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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