TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Need help maching and comparing decimal numbers.

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
elminster



Joined: 13 Jul 2009
Posts: 46

PostPosted: Mon Nov 28, 2016 4:36 pm    Post subject: Need help maching and comparing decimal numbers. Reply with quote

I have a line that looks like this:

HO:0.00/0 HI:0.00/0 LO:15.27/0 LI:0.00/0 Enemy:perfect

I'm kind of low end skills here, and normally just grab numbers like this:

^HO:%d.%d/%d HI:%d.%d/%d LO:%d.%d/%d LI:%d.%d/%d Enemy:%w

But in this case I want the whole decimal number (from 0.00 up to 100.00) after HO, HI, LO and LI. And then... some way to find which one has the highest value of the 4.

Appreciate any help!
Back to top
View user's profile Send private message AIM Address
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Wed Nov 30, 2016 3:29 pm    Post subject: Reply with quote

I only included recognition for the numbers you mentioned, but should be easy to add every other parameter that you need.

The trick to get the number with decimals is this regexp {[0-9]*\.[0-9]*}

The rest should be easy to understand

Code:

#action {^HO:{[0-9]*\.[0-9]*}/0 HI:{[0-9]*\.[0-9]*}/0 LO:{[0-9]*\.[0-9]*}/0 LI:{[0-9]*\.[0-9]*}/0 Enemy:%*}
{
#var Value[HO] {%1};
#var Value[HI] {%2};
#var Value[LO] {%3};
#var Value[LI] {%4};
#var TheMajor {};
#var MaxValue {0};

#foreach $Value[] {meow} {#IF {$Value[$meow]>=$MaxValue} {#var TheMajor {$meow};#var MaxValue {$Value[$meow]}} {}};

#echo {The highest is: $TheMajor = $MaxValue};
}


Code:

#SHOW {HO:301.01/0 HI:301.02/0 LO:15.27/0 LI:3.03/0 Enemy:perfect}
The highest is: HI = 301.02
Back to top
View user's profile Send private message
elminster



Joined: 13 Jul 2009
Posts: 46

PostPosted: Fri Dec 23, 2016 8:49 am    Post subject: Reply with quote

Thanks very much for the help. This worked great!
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group