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
myddrun
Wanderer


Joined: 31 Mar 2005
Posts: 58

PostPosted: Tue Feb 02, 2010 2:42 pm   

How do I ignore certain lines when using subregex
 
I'm using some code to grab a list of all players on line at a given time. The output is basically as follows.

Code:
------------------] Players [----------------------------------
Name1            Name2                  Name3          Name4    Name5
Name6            Name7                  Name8          Name9    Name10
-----------> TEXT HERE CAN CHANGE <---------------------


The number of spaces between the names can change and so can the text between the > < .

I’m using code something like this

Code:
#TRIGGER "WhoStart" {-----~] Players ~[--------} {#VAR PlayerList ""}

#COND {(*)} {#FORALL %subregex( "%1"+, "\s+|-|>|<", "|") {#ADDITEM Playerlist "%i"}} {manual}

#TRIGGER "WhoStop" {----~> There are (*) players ~<--- } {#VAR PlayerCount %1;#STATE WhoStart 1}


I can get everything I need to in to a string list. However it’s also includes the last line where I’ve put “Text Here Can Change”. I can filter out the the - < and > characters, but it still grabs the "TEXT HERE CAN CHANGE" part of the line.

In this code is there any way I can ignore any line starting with a hyphen so it doesn’t pass the words in to my variable?

Thanks!


Last edited by myddrun on Thu Feb 04, 2010 1:23 pm; edited 2 times in total
Reply with quote
myddrun
Wanderer


Joined: 31 Mar 2005
Posts: 58

PostPosted: Tue Feb 02, 2010 5:30 pm   
 
Just had a thought of course. I'll try messing about with that (*) in the Cond trigger. Confused
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Feb 02, 2010 7:20 pm   
 
#if (%1 = %begins(%1,"-")) {stuff you do for the hyphen lines;#state WhoStart 0} {stuff you do to grab who names}

WhoStop doesn't need the #state command, either. With it there, the WhoStart Trigger will never fire on the initial hyphen line on subsequent uses (thereby not resetting your player variable) and your #condition pattern will be essentially exposed to the entire text stream from the game.
_________________
EDIT: I didn't like my old signature
Reply with quote
myddrun
Wanderer


Joined: 31 Mar 2005
Posts: 58

PostPosted: Wed Feb 03, 2010 7:42 am   
 
MattLofton wrote:
#if (%1 = %begins(%1,"-")) {stuff you do for the hyphen lines;#state WhoStart 0} {stuff you do to grab who names}

WhoStop doesn't need the #state command, either. With it there, the WhoStart Trigger will never fire on the initial hyphen line on subsequent uses (thereby not resetting your player variable).


I think that was a typo on my part. My whostop has #State Whostart 0 not 1. :)

Anyway, I messed around the trigger in the cond from (*) to ([A-Za-z ~ ]) to only trigger on lines with letters or spaces.

It's been so long that I've player with zmud that I've nearly forgotten the little I knew. :D
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