 |
Evangelist Adept
Joined: 10 Oct 2000 Posts: 224 Location: USA
|
Posted: Wed Nov 20, 2002 5:04 am
Trouble with math |
Sadly, I am having trouble with the #MATH command. I can get it to work, but I need it to do like (x/y)*z
I tried this.
stat
#VAR perchp1 %eval((@currhp/@maxhp) * 100)
#VAR perchp2 %eval(@perchp1 * 100)
#VAR percmana1 %eval(@currmana/@maxmana)
#VAR percmana2 %eval(@percmana1 * 100)
#VAR percmoves1 %eval(@currmoves/@maxmoves)
#VAR percmoves2 %eval(@percmoves1 * 100)
#WAIT 1000
#ECHO STATUS: @perchp2% HP, @percmana2% MANA, @percmov2% MOVES
stat is a command in the mud I play
I also tried #MATH perchp ((@currhp/@maxhp)*100) as well as #VAR perchp %eval((@currhp/@maxhp)*100). When I am at max hp it reports 100% hp no problem, I think the problem may be that the numbers divided dont always produce a whole number as a result...so instea of 5 10 50, it may be like 5.5 56.335 or whatnot, could that have an impact, and if so, how can i correct it?
Evangelist/Pernius
www.phidar.com/phidar.html |
|
|
 |
Castaway GURU

Joined: 10 Oct 2000 Posts: 793 Location: Swindon, England
|
Posted: Wed Nov 20, 2002 9:17 am |
You're right, thats the problem. zMUD only deals with whole numbers, so when you do something like 1/2 you dont get 0.5, but 1 (rounded up) and 1/3 is not 0.333 but 0 (rounded down as its less than 0.5)
So, in order to get a percentage, you have to do it the other way around:
(@currhp*100)/@maxhp
So you get instead of:
20/200 = 0.1*100 (The 0.1 was rounded to 0 by zmud, giving 0*100)
this:
(20*100)/200 = 10
Lady C. |
|
|
 |
Evangelist Adept
Joined: 10 Oct 2000 Posts: 224 Location: USA
|
Posted: Thu Nov 21, 2002 6:56 am |
That is still not working...it is either showing up as 0% or 100%, nothing in between :( Any other suggestions
Evangelist/Pernius
www.phidar.com/phidar.html |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Nov 21, 2002 8:28 am |
stat
#VAR perchp1 %eval((@currhp * 100)/@maxhp)
#VAR percmana1 %eval((@currmana * 100)/@maxmana)
#VAR percmoves1 %eval((@currmoves * 100)/@maxmoves)
#ALA +1 {#ECHO STATUS: @perchp1% HP, @percmana1% MANA, @percmov1% MOVES}
NOTE: This is just a repeat of what Lady C. already told you.
LightBulb
Senior Member |
|
|
 |
Evangelist Adept
Joined: 10 Oct 2000 Posts: 224 Location: USA
|
Posted: Fri Nov 22, 2002 5:49 pm |
Still is not working properly. Should the result still come out with non even numbers? Like, what if the result happens to be 5.33666445454667%...will zmud do that or is there a way to limit it to say 5.33%.
It may just be a setting or something, but I cannot get it to work properly. |
|
|
 |
Evangelist Adept
Joined: 10 Oct 2000 Posts: 224 Location: USA
|
Posted: Fri Nov 22, 2002 5:54 pm |
Update:
Here is an example. Say I have 1533 hp and my max is 2271..I get this
(currhp*100)/@maxhp= 1533* 100= 153300/2271=67.503302050991....can zmud show that as a result? Kjata said zmud only deals with whole numbers...i do not know if this is doable or not :(
Evangelist/Pernius
www.phidar.com/phidar.html |
|
|
 |
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Nov 22, 2002 8:10 pm |
zMUD 6.16 only works with integers. So, using your example:
(@currhp*100)/@maxhp = (1533*100)/2271 = 153300/2271 = 67
The remainder is ignored.
LightBulb
Senior Member |
|
|
 |
|
|