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


Joined: 14 Jul 2003
Posts: 5

PostPosted: Tue Jan 12, 2010 5:44 pm   

group capture window
 
I would like to capture the following to a window, with the number in the group defining the number of lines to capture. It seems the paren is interfering. The P1 P2 are player names.

Your group consists of ( 9/30):
( Head) 1301/1301 hit, 191/191 move P1
(Front) 901/901 hit, 125/125 move P2
(Front) 837/867 hit, 195/195 move P3
(Front) 933/933 hit, 130/130 move P4
(Front) 895/895 hit, 220/220 move P5
(Front) 886/762 hit, 175/175 move P6
(Front) 727/727 hit, 159/159 move P7
(Front) 856/856 hit, 156/156 move P8
(Front) 363/363 hit, 150/150 move P9
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Jan 12, 2010 6:26 pm   
 
Include the parentheses in your pattern, with a tilde (~) immediately preceding it (see the prior set of parentheses, specifically the ending bracket.)

Parentheses are used to capture pattern information into system variables named %1 to %99.
_________________
EDIT: I didn't like my old signature
Reply with quote
eyeshade
Newbie


Joined: 14 Jul 2003
Posts: 5

PostPosted: Tue Jan 12, 2010 6:40 pm   
 
What would be the pattern to capture the lines? I have this:
#tr {Your group consists of ~((%d)/30~):$} {#cap %1 group}

But Capture is capturing the lines above not below the statement, any ideas?

Ok so I created a class called it groupcapture had it add one to a variable at each (Head) or (Front) then the #cap command uses that variable and it works, but my pattern above with %d only works if group size is 2 digits. Why?
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Tue Jan 12, 2010 8:47 pm   
 
Because if the group size has only one digit, then there's a space in front of it. Note ( 9/30) instead of (9/30). I'm not sure how to match that as a ZMud-style pattern. In a regular expression, it would be
Code:
Your group consists of \( ?\d+/30\):
You might also want ^ and $ to fix it to the start and end of the line.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Jan 12, 2010 9:11 pm   
 
You can't do it with the #cap command, because as you say, it will capture lines above the triggering line. What you need is a multi-state trigger, with the second state looping the correct number of times.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Jan 12, 2010 10:26 pm   
 
Code:

#trigger "tGroup" {Your group consists of ~({ |}%d/%d~):} {}
#condition {(*)} {
  #if (%1 = "[b]something that appears after the last line in the group list[/b]") {#state tGroup 0} {#capture windowname}
} {manual}


Code:

#trigger {Your group consists of ~({ |}(%d)/%d~):} {
  #trigger "tGroupList" {^~(*~) %d/%d hit, %d/%d move *} {#capture windowname} "" {LoopLines|param=%1}
}


The first code-block is how it's traditionally done, since most looping situations aren't so easily defined. No need to worry about how many times to iterate, because most games don't try to double-space the output of any given command (thus, no whitespace between multi-line lists).

The second one I have no idea if it'd even work on acount of the second #TRIGGER simply creating multiple triggers instead of redefining the one trigger named tGroupList. The downside is that the two triggers are not related to each other in any way so you have to make sure the second trigger is not triggered by any other output or in situations where you need a different set of actions.
_________________
EDIT: I didn't like my old signature
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