 |
khadgarion Newbie
Joined: 03 Jun 2008 Posts: 4
|
Posted: 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? |
|
|
 |
mr_kent Enchanter
Joined: 10 Oct 2000 Posts: 698
|
Posted: 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 |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
 |
khadgarion Newbie
Joined: 03 Jun 2008 Posts: 4
|
Posted: 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!! |
|
|
 |
Toxic Adept
Joined: 27 May 2008 Posts: 299
|
Posted: Tue Jun 03, 2008 6:43 pm |
Yes, I would use (%x). Instead of (%n)
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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.
|
|
|
 |
Toxic Adept
Joined: 27 May 2008 Posts: 299
|
Posted: 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. |
|
|
 |
khadgarion Newbie
Joined: 03 Jun 2008 Posts: 4
|
Posted: 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...?
|
|
|
 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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 |
|
|
 |
khadgarion Newbie
Joined: 03 Jun 2008 Posts: 4
|
Posted: 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 |
|
|
|
 |
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Jun 05, 2008 8:54 am |
%n is working fine. I have no idea why it's not in this case.
|
|
|
 |
Toxic Adept
Joined: 27 May 2008 Posts: 299
|
Posted: Thu Jun 05, 2008 1:39 pm |
It was probably the space in the very beginning messing up the pattern, not the %n.
|
|
|
 |
|
|