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
Mhildrum
Beginner


Joined: 03 Aug 2004
Posts: 11
Location: Seattle

PostPosted: Fri Aug 13, 2004 5:00 pm   

Help with pattern matching
 
From looking through old posts, I found that triggers won't fire multiple times on a line, which is kind of unfortunate for what I am doing, but still doable. Let me first state what I am trying to accomplish:

I want to populate a list with playernames, for reasons such as disabling triggers when players enter my room and whatnot. The easiest way for me to do this is the "who" command. Output of the command is below. (Note, underscores aren't really there, just represent spacing, which I don't know how to represet in these posts)

[140] Lothar______{103} Calin________{75} Yoarn________[35] Niem

I would like to capture all the names into my variable. The list is never more than 4 columns long, but sometimes not all oputput is 4 columns, i.e. only 2 columns in the last line. The solution I can see involves making a trigger for every possilbe situation. abbreviated:

[] [] [] []
[] [] [] {}
[] [] {} []
etc. for all lengths of culumns.

Is there another solution?

More output
[140] Lothar {103} Calin {75} Yoarn [35] Niem
{135} Magnum {103} Gorm [72] Makta [30] Chael
[115] Hitaru {100} Anomalie {71} Suravette {30} Koga
[115] Trajan [94] Saladin {62} Lessa [30] Silk
[110] Bender {85} Multani [52] Ashram [17] Trent
{108} Juele {75} Afterlife {40} Alucard {11} Spiff
[106] Tuck

Thanks for looking
Michael
Reply with quote
Morgoth
Beginner


Joined: 07 Apr 2004
Posts: 12
Location: Israel

PostPosted: Fri Aug 13, 2004 8:04 pm   
 
I'm not sure this would work, but you could try

#TRIGGER {?%d? (%w)} {#ADDITEM NAMELIST %1}


Just a poor attempt, maybe it'll work though :).
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Aug 13, 2004 10:51 pm   
 
This is untested.

#TR {{~{|~[}%d{~}|~]} %w} {#VAR NameList {%concat(@NameList,,"|",%word(%line,2),"|",%word(%line,4),"|",%word(%line,6),"|",%word(%line,8))};#DELITEM NameList {}}

This trigger assumes you have anoother trigger/alias to blank the variable NameList, and should be assigned an ID and turned off with #T- when not in use.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Aug 14, 2004 12:37 am   
 
You have punctuation (includes spaces), digits, and letters. These all have individual wildcards, so four triggers should be sufficient:
Code:

#TR {%p%d%p (%w)} {#ADDI Namelist %1}
#TR {%p%d%p (%w) %p%d%p (%w)} {#ADDI Namelist %1;#ADDI Namelist %2}
#TR {%p%d%p (%w) %p%d%p (%w) %p%d%p (%w)} {#ADDI Namelist %1;#ADDI Namelist %2;#ADDI Namelist %3}
#TR {%p%d%p (%w) %p%d%p (%w) %p%d%p (%w) %p%d%p (%w)} {#ADDI Namelist %1;#ADDI Namelist %2;#ADDI Namelist %3;#ADDI Namelist %4}


It would probably be best to keep these in a separate class which will only be enabled when you want to add to the list.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Mhildrum
Beginner


Joined: 03 Aug 2004
Posts: 11
Location: Seattle

PostPosted: Sun Aug 15, 2004 9:33 pm   
 
It never ceases to amaze me how helpful everyone is here. As soon as I get home, I will put it together and try it out. Thanks a lot.

Michael
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