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


Joined: 07 Feb 2008
Posts: 2

PostPosted: Thu Feb 07, 2008 9:10 pm   

Text parsing
 
How can i parse out the info in this string.

485h, 550m ex-

so that i can store the 485h as a health var and stick it in a status bar. What is the correct syntax to complete this?
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu Feb 07, 2008 9:22 pm   
 
Code:

#trigger {(%d)h, (%d)m ex~-} {health=%1;mana=%2}


This trigger captures the health/mana amounts into variables, then you can put both variables on status bar.

I used the tilde ("~") just in case to escape the "-". Perhaps its not needed, so in case the trigger doesn't work, just remove it.


Prog
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Thu Feb 07, 2008 11:54 pm   
 
ooooo looks like Achaea. ya know that string changes all about

this is true:

Code:
^(%d)h~, (%d)m *


but those little letters are good too till you end up with something like Larkin's

Code:
^(?Health:\d+)h\, (?Mana:\d+)m(?:\, (\d+)(e))?(?:\, (\d+)(w))? (?PromptFlags:[cexkdb@]*)(?: Vote)?\-


that above is regex-cellent and included in ACP - the Achaean Curing Project

oh, too, there is a check box for prompts in the trigger, you might want that

I think the tilde is there because I pulled it out of the mapper, I have worked with this prompt a while and random do things like that
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Feb 08, 2008 10:29 am   
 
The tilde is there because the comma is punctuation and whoever wrote the pattern was a bit overzealous :P Same with all the quoted commas in your regex.

Were it me (since the prompt flags are always in the same order) I'd use

c?e?x?k?d?b?@?

instead.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
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