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


Joined: 27 Jun 2012
Posts: 17

PostPosted: Thu Aug 09, 2012 4:11 am   

Variable calculation problem
 
I've got a record variable called BodyHits that has 7 different items in it. right leg, left leg, right arm, left arm, gut, chest, head.
Everytime I get hit on a certain limb I increment it by 1.

I'd like to be able to sort through the variable and find the largest two.
How would I go about this?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4682
Location: Pensacola, FL, USA

PostPosted: Thu Aug 09, 2012 7:30 am   
 
$temp=@bodyhits
$first=%dbkey($temp, %isvalue($temp, %max($temp)))
#DELKEY $temp $first
$second=%dbkey($temp, %isvalue($temp, %max($temp)))

that should define the two largest keys of your @bodyhits variable as $first and $second respectively
_________________
Discord: Shalimarwildcat
Reply with quote
Rastamutti
Beginner


Joined: 27 Jun 2012
Posts: 17

PostPosted: Thu Aug 09, 2012 12:34 pm   
 
Thanks! Easy and quick answer. Was hoping it was that way.
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