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: Fri Nov 04, 2005 7:56 pm   

Yet another parsing names in to a lists question.
 
I'm stumped and I dont even know where to start.

I get a list of names like this :

----------------------------------] Players [----------------------------------
Name1 Name2 Name3 Name4 Name5
Name6 Name7 Name8 Name9 Name10
-----------> There are Ten players <---------------------------------------


(By definition the last line also isn't set since Number words are used as well.)

There is no set fix number of spaces between each name since the layout (and hence the number of names on each line) depends on how many people are on.

What do I need to do to get each name in to a list?

Thank you kindly!
Reply with quote
Tech
GURU


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

PostPosted: Fri Nov 04, 2005 10:08 pm   
 
Try this for starters

Code:
#TR {----------------------------------] Players [----------------------------------} {#VAR PlayerList }
#COND {(*)} { #VAR Temp %subregex( "%1", "\s+", "|"); #FORALL @Temp {#ADDITEM PlayerList %i} }
#COND {-----------> There are (*) players <--------------------------------------- } {#VAR PlayerCount %1 }
_________________
Asati di tempari!
Reply with quote
myddrun
Wanderer


Joined: 31 Mar 2005
Posts: 58

PostPosted: Sat Nov 05, 2005 8:46 am   
 
Thanks Tech, thats a great help!
There's a slight glitch since its only parsing the first row of names :(

I gather the fact that it uses Nineteen not 19 doesn't matter at all?

But thank! I didn't know you could do what you've suggested!

Mydd.
Reply with quote
Tech
GURU


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

PostPosted: Mon Nov 07, 2005 3:29 am   
 
Yeah.. I'm glad it helped. I didn't really test out the code, but I'm sure you can figure out the glitch. And actually as I'm typing I realized it.

Change

Code:
#COND {(*)} { #VAR Temp %subregex( "%1", "\s+", "|"); #FORALL @Temp {#ADDITEM PlayerList %i} }
#COND {-----------> There are (*) players <--------------------------------------- } {#VAR PlayerCount %1 }

to
Code:
 #COND {(*)} { #IF (%match(%1, "-----------> There are (*) players <--------------------------------------- ") { #VAR PlayerCount %1 } { #VAR Temp %subregex( "%1", "\s+", "|"); #FORALL @Temp {#ADDITEM PlayerList %i}; #STATE 1}


Also untested but should do the trick.. I was only matching the line once.
_________________
Asati di tempari!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Mon Nov 07, 2005 5:45 pm   
 
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}


This should work for you.
_________________
Zmud Support Library
Zmud Knowledge Base
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