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
HerenIstarian
Novice


Joined: 30 Oct 2005
Posts: 40

PostPosted: Mon Apr 19, 2010 9:39 am   

Trouble capturing battle prompt.
 
Okay I have this pesky battle prompt that's always given me trouble:
Code:

F : [    2%    ] - S : [    1%    ] - N : None - I : [    70%   ]
F : [    20%   ] - S : [    4%    ] - N : None - I : [   100%   ]

Notice how when there is more digits the amount of spaces changes?

I've tried a variety of ways to capture it, for example:
^F : ~[* (%d)~% *~] - S : ~[* (%d)~% *~] - N ~: &{nervature} - I : ~[* (%d)~% *~]$

This one though doesn't capture the pattern at all. Another one would capture the pattern
and the variables but the variables would have spaces before the numbers. So basically
I'm trying to get it to both capture the line regardless of spaces and then also ignore the
spaces once captured. I've gotten help from several CMUD users but none were able to
successfully help me. Any suggestions?
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Mon Apr 19, 2010 11:08 am   
 
^F : ~[%s(%d)~%%s~] - S : ~[%s(%d)~%%s~] - N ~: &{nervature} - I : ~[%s(%d)~%%s~]$
_________________
Taz :)
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Apr 19, 2010 5:56 pm   
 
%s, in case you're curious, will capture variant amount of spaces. It is equivalent to \s+ in regex.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
HerenIstarian
Novice


Joined: 30 Oct 2005
Posts: 40

PostPosted: Mon Apr 19, 2010 9:58 pm   
 
I appreciate the help unfortunately the suggested pattern didn't capture. I've tried changing it slightly,
I removed the () around %d, I also added spaces between the ~%%s because both % were coming up
highlighted. Still nothing works. Any other ideas?

This was the one pattern that I made that actually captured but it captured the spaces as well.

F ~: ~[%1~%*~] - S ~: ~[%2~%*~] - N : &{nervature} - I : ~[%3~%*~]

#VAR fatigue %replace(%1, ,"")
#VAR stress %replace(%2, ,"")
#VAR intensity %replace(%4, ,"")


EDIT:
I may have found a solution
F ~: ~[%s%1~%*~] - S ~: ~[%s%2~%*~] - N : &{nervature} - I : ~[%s%3~%*~]

#VAR fatigue %replace(%1, ,"")
#VAR stress %replace(%2, ,"")
#VAR intensity %replace(%4, ,"")

This seems to work nicely so far, thanks for the help :)


Last edited by HerenIstarian on Mon Apr 19, 2010 10:27 pm; edited 1 time in total
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Apr 19, 2010 10:27 pm   
 
1)don't use %1...%99 in trigger patterns. If you need a helpfile reference for wildcards, check out Pattern Matching.

2)remove the {} from around nervature. {} denote a stringlist, which is not what you are wanting to use if the & is any indication. The correct form is &varname. You can also limit the matching power of &varname using wildcards, ie, &%wnervature.

3)if your prompt doesn't end with a newline, remove the $ and check/uncheck Trigger on Newline (trigger will fire when the current line ends with a newline) and Trigger on Prompt (trigger will fire as soon as the pattern matches) as appropriate.
_________________
EDIT: I didn't like my old signature
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Tue Apr 20, 2010 12:17 am   
 
It's most likely number 3 that you need to take notice of because I tested the trigger pattern I gave you with the examples you provided and both matched.
_________________
Taz :)
Reply with quote
chumppi
Newbie


Joined: 04 Jan 2009
Posts: 8
Location: Vaasa, Finland

PostPosted: Wed Apr 21, 2010 11:29 am   
 
Yup, I play on the same mud and this:
^F : ~[* (%d)~% *~] - S : ~[* (%d)~% *~] - N ~: &{nervature} - I : ~[* (%d)~% *~]$
... works perfectly for me with the newest CMUD beta.
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