The Daily Click ::. Forums ::. Klik Coding Help ::. MMF2 / decimals
 

Post Reply  Post Oekaki 
 

Posted By Message

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
16th March, 2007 at 12:15:51 -

I'm trying to get a counter to show the players health in percent. So, for example, if the player had 15/20 health, then the counter would say 75%. I'm using this formula:

100 / (Value("HP") / Value("HP max"))

However, MMF seems to round off the value of (HP / HP max) every time. So instead, if the player had 15/20 health, it wouldn't return 1.333, but MMF would round it off to 1.0, so the counter would say 100%. I've tried sticking random .0's in there, and I've tried multiplying/dividing with 1.0 everywhere to get MMF to work with decimals, but it doesn't seem to work.

I have a feeling there's a very simple answer to this, that I might even have used before in MMF 1.5, but I just can't come up with anything

 
n/a

Deleted User
16th March, 2007 at 12:32:12 -

I remember having the same problem using the MMF 2 demo, are you sure you've got the latest version/build of MMF 2?
That's all I can think of E_E

 

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
16th March, 2007 at 12:32:56 -

I checked this other MMF 1.5 app I made, where I had used the very same formula, and it worked fine. Bah!

I've got build R243.

Image Edited by the Author.

 
n/a

Deleted User
16th March, 2007 at 12:34:54 -

Do you like onion? That might be the problem. .__.

 

Ski

TDC is my stress ball

Registered
  13/03/2005
Points
  10130

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!KlikCast HelperVIP MemberWii OwnerStrawberryPicture Me This Round 28 Winner!PS3 OwnerI am an April Fool
Candy Cane
16th March, 2007 at 12:39:44 -

oh god, hes spamming again Alert Admin!

 
n/a

David Newton (DavidN)

Invisible

Registered
  27/10/2002
Points
  8322

Honored Admin Alumnus
16th March, 2007 at 12:44:22 -

Your formula for percentage seems to be wrong (though it's probably just a typo) - you'd need to use (100 * Current HP)/Max HP. Multiplying first will make the rounding error less catastrophic.

 
http://www.davidn.co.nr - Games, music, living in America

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
16th March, 2007 at 12:50:24 -

Oh God, how stupid X_X

Yarr, thanks DavidN!

 
n/a

Deleted User
16th March, 2007 at 12:57:39 -

Lol, that has happened to me too often x)

 

jpSoul



Registered
  25/10/2003
Points
  1714
17th March, 2007 at 02:37:55 -

to have a float result it's simple, you have to do:
100.0 / (Value("HP") / Value("HP max"))

 
n/a

X_Sheep

I had a custom rating before it was cool

Registered
  01/03/2004
Points
  1313

VIP MemberPicture Me This -Round 23- Winner!Dos Rules!
17th March, 2007 at 04:04:02 -

Well no, that would be
100.0 * (Value("HP") / Value("HP max"))

 
a/n

jpSoul



Registered
  25/10/2003
Points
  1714
17th March, 2007 at 07:42:54 -

yes it was just an example with the first formula of the topic

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
17th March, 2007 at 07:56:24 -

Okay, enough. Let this topic die already

Image Edited by the Author.

 
n/a

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
19th March, 2007 at 03:08:28 -

i remember having this problem even back in TGF. I fixed it, and i think i did it by dividing with 1.0, just don't remember what i divided it with i used this in my Monster Combat game though, so if needed i can look through it when i get home.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click