BREAKING DOWN NUMBERS

Posts

Pages: 1
Right so I'm trying to make my CMS and one aspect of it is showing the character's current HP with an image representing each digit. To do this obviously I've got to break down the HP value into hundreds, tens and units and store each in a variable. How do I go about doing this? It's probably very simple but I suck at maths to put it bluntly.
You could use simple division and modulo.

say you had a number 459. Since RM2k3 truncates decimal points, 459/100 = 4. 459 mod 100 = 59/10 = 5. 459 mod 10 = 9.

Something like that.
It's just the tens column I can't get to work properly. With your example of 459 I get the value of 59 rather than 5 when I MOD it by 100.

EDIT - forgot to divide by 10. My bad.

EDIT 2- Thanks kentona it works great!
LouisCyphre
can't make a bad game if you don't finish any games
4523
post=91670
say you had a number 459. Since RM2k3 truncates decimal points, 459/100 = 4. 459 mod 10 = 59/10 = 5. 459 mod 100 = 9..


Kent had his numbers backwards.
One last thing - how can I hide the leading zeros when my character's HP is below 100 or 10?
LouisCyphre
can't make a bad game if you don't finish any games
4523
Easy.

Make a conditional branch checking to see if the hero's total HP is 10 or greater. If so, it shows the tens digit. Make one set for 100 HP or greater and repeat.
Pages: 1