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
takke
Beginner


Joined: 11 Oct 2002
Posts: 29
Location: Sweden

PostPosted: Tue Aug 29, 2023 8:05 am   

Help with capture to variable
 
Hi peeps

I need help to capture the following string: Exp: 10903900 (Safe: 0, Latent: 0) Next Level: 36590500 (29.8%)

and capture the values into variables. I can't seem properly match this string.

Thanks in advance
Reply with quote
mikeC130
Apprentice


Joined: 03 Jul 2006
Posts: 110

PostPosted: Tue Aug 29, 2023 1:01 pm   
 
The following should do it.
Quote:
<trigger name="Test 29 Aug 23" priority="400" trigontrig="false" id="40">
<pattern>Exp:%s(%d) ~(Safe: (%d), Latent: (%d)~) Next Level:%s(%d) ~((*)~%~)</pattern>
<value>#VAR Xp %1
#VAR Sa %2
#VAR La %3
#VAR NextLev %4
#VAR Percent %5
#CALL %vartype(Percent,7)// set @Percent to floating point value
</value>
</trigger>
[/quote]
This will save all of the number values, with the percentage saved as a floating point value showing the percentage - i.e. 29.8 in your sample text
Variable names are Xp, Sa, La, NextLev, and Percent.
Reply with quote
takke
Beginner


Joined: 11 Oct 2002
Posts: 29
Location: Sweden

PostPosted: Wed Aug 30, 2023 4:04 am   
 
mikeC130 wrote:
The following should do it.
Quote:
<trigger name="Test 29 Aug 23" priority="400" trigontrig="false" id="40">
<pattern>Exp:%s(%d) ~(Safe: (%d), Latent: (%d)~) Next Level:%s(%d) ~((*)~%~)</pattern>
<value>#VAR Xp %1
#VAR Sa %2
#VAR La %3
#VAR NextLev %4
#VAR Percent %5
#CALL %vartype(Percent,7)// set @Percent to floating point value
</value>
</trigger>

This will save all of the number values, with the percentage saved as a floating point value showing the percentage - i.e. 29.8 in your sample text
Variable names are Xp, Sa, La, NextLev, and Percent.[/quote]

Thanks m8, this worked like a charm, the biggest problem i had was with the percentagevalue :)
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