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


Joined: 03 Jun 2008
Posts: 4

PostPosted: Tue Jun 03, 2008 8:06 am   

problem capturing number in parentheses
 
Hi there!
I'm trying to capture my max hp, and here is the mud's promt:

Code:
Hp: 1078(1078)  Gp: 50(50)  Xp: 730,300  Socp: 76(76)


with this trigger:

Code:
Hp: %d(%d)  Gp: %d(%d)  Xp: *  Socp: %d(%d)


I just can't get it to work. I have tried to escape the parentheses (maybe i don't know the right char)

Help please?
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Tue Jun 03, 2008 8:59 am   
 
Code:



#TRIGGER {Hp: (%d)~((%d)~) Gp: (%d)~((%d)~) Xp: %n Socp: (%d)~((%d)~) } {#VAR HP %1;#VAR MAX_HP %2;#VAR GP %3;#VAR MAX_GP %4;#VAR SOCP %5;#VAR MAX_SOCP %6} "" "PROMPT"




EDIT: Added prompt option and changed the XP# to %n.


Last edited by mr_kent on Tue Jun 03, 2008 9:03 am; edited 2 times in total
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jun 03, 2008 9:01 am   
 
%d won't work for the XP number. You'll need to use %n Hp: (%d)~((%d)~) Gp: (%d)~((%d)~) Xp: %n Socp: (%d)~((%d)~) and if you want to use the value for anything, you'll want to put brackets () round it like there are round the other wildcards.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
khadgarion
Newbie


Joined: 03 Jun 2008
Posts: 4

PostPosted: Tue Jun 03, 2008 6:36 pm   
 
Thanks much for the replies!
I'm still having a problem.

I have this for the pattern:
Code:
Hp: (%d)~((%d)~)  Gp: (%d)~((%d)~)  Xp: (%n)  Socp: (%d)~((%d)~)

and for the value:
Code:
#VAR hp %1
#VAR maxhp %2
#VAR gp %3
#VAR maxgp %4
#VAR sp %5
#VAR maxsp %6


When i go to "test" it with the test tab, i use this pattern i copied from the mud output:
Code:
Hp: 1094(1094)  Gp: 50(50)  Xp: 938,879  Socp: 88(88)


It says "pattern doesn't match".

If I use the "default" pattern matching test, of this:
Code:
Hp: 123(123)  Gp: 123(123)  Xp: -123  Socp: 123(123)

It matches just fine. is the "Xp" number messing up the whole string?

Thanks for your help!!
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Tue Jun 03, 2008 6:43 pm   
 
Yes, I would use (%x). Instead of (%n)
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jun 03, 2008 8:51 pm   
 
Also remember that with your altered pattern (you added a set of brackets () ) that sp will be %6 and maxsp %7. xp is %5.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Tue Jun 03, 2008 8:53 pm   
 
Also remember you might want to strip out the , contained in the number and convert it to a integer instead of a string.

Just depends on what you plan on doing it with it later as to whether that is necessary or not.
Reply with quote
khadgarion
Newbie


Joined: 03 Jun 2008
Posts: 4

PostPosted: Tue Jun 03, 2008 10:42 pm   
 
I did change xp to %x, in brackets. I still can't get it to capture the numbers. I wonder what I am doing wrong...?
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Jun 03, 2008 10:56 pm   
 
Spacing could be off. For every place where there are spaces, delete all the spaces and change it to %s. I know in the MUD I play, spacing is determined by the number of digits.

Charneus
Reply with quote
khadgarion
Newbie


Joined: 03 Jun 2008
Posts: 4

PostPosted: Wed Jun 04, 2008 4:48 am   
 
Charneus, I tried what you suggested....

It didn't work. Supremely confused, i looked at every character of the "test" pattern.

There was a trailing space in the original pattern. I deleted the space, and BAM!!!

It works!!

Thanks for you help everyone!!

For those that are interested, here's the code:
Code:
Pattern:
Hp:%s(%d)~((%d)~)%sGp:%s(%d)~((%d)~)%sXp:%s(%x)%sSocp:%s(%d)~((%d)~)
#VAR hp %1
#VAR maxhp %2
#VAR gp %3
#VAR maxgp %4
#VAR sp %6
#VAR maxsp %6
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Jun 04, 2008 11:02 pm   
 
%n is supposed to work on formatted numbers. If it's not working, that's a bug.
_________________
EDIT: I didn't like my old signature
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Thu Jun 05, 2008 8:54 am   
 
%n is working fine. I have no idea why it's not in this case.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Thu Jun 05, 2008 1:39 pm   
 
It was probably the space in the very beginning messing up the pattern, not the %n.
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