-
Percentages?
Hello, I'm making a game and I want to show the percent of your hp, like 56% of hp left or something like that, but MMF2 doesn't seem to like decimals. Right now I'm doing this for the equation, which only works when the value is 100%:
value( "hp" )/maxvalue( "hp" )*100)
Is there a different equation I could use? An extension? Thanks
-
Re: Percentages?
Try forcing MMF to use decimals like: value( "hp" )/(maxvalue( "hp" )*100.0)
-
Re: Percentages?
Thanks, it worked! One more question, how would i make it round to the hundredths place? The Round() function rounds to the nearest whole number.
-
Re: Percentages?
Multiply it by 100, round it, and then divide it by 100.
Try this:
Round(value( "hp" )/(maxvalue( "hp" )*100.0)*100)/100
Wow! That's a lot of 100's!!! :D
-
Re: Percentages?
Hmmm... that should work but for some reason it doesn't. Heres what I have:
The original:
value( "exp" )/(maxvalue( "exp" )*1.0)*100
With the thing:
Round((value( "exp" )/(maxvalue( "exp" )*1.0)*100 )*100)/100
But it still displays as a whole number(9, 100, 50, etc.) instead of 9.54, 100.00, 50.45 etc.
EDIT:
Nevermind, If I don't divide it by 100 at the end it works! Thanks for the help. Now I have to find a way to stick a . in there...
-
Re: Percentages?
Ok, I got the decimal in there, using this:
Str$(value( "exp" )/(maxvalue( "exp" )*1.0)*100)+"."+Str$(Round(((value( "exp" )/(maxvalue( "exp" )*1.0)*100)*100)-(value( "exp" )/(maxvalue( "exp" )*1.0)*100)))
BUT the digits after the decimal wont round..
Edit: Ah well, for now I'll just change the size of the string so the extra digits wont be seen.
-
Re: Percentages?
str$( round( value( "exp" ) * 100 * 100.0 / maxvalue( "exp" ) ) / 100.0 )
Should do it, including putting in the "." and two decimal places
EDIT: though as 1/100 is a recurring number in binary, you may not end up with only two places :(