hp/mp number into percentage?

hi! i was wondering if it was possible to change the hp/mp from this:
1612537920649.png

into this:
1612537934633.png

i dont want it to change the way the hp/mp is affected
i just want it to say "57%" instead of "57 / 100"

if there is a way to do this, please let me know!
thank you very much! :0)
yes, any form of menu change is possible to be programmed in.
you just have to have a script to do this

And I think you'll have to request a custom script for this as I do't remember any sript doing this was ever written (most people prefer the absolute number to percentages, especially since most games continuously increase the maximum HP and that would never be visible with this kind of display.
i see thank you :0)
do you think it would be possible for this to be moved to script requests?
Should HP and MP be drawn as percentage everywhere or only in the menu?
Should HP and MP be drawn as percentage everywhere or only in the menu?
only in the menu :0)
@whotfisjojo I like the idea!

I've moved this thread to RGSS3 Script Requests. Thank you.

Ruby:
class Window_MenuStatus
  def draw_current_and_max_values(x, y, width, current, max, color1, _color2)
    percentage = "#{(current.fdiv(max) * 100).ceil}%"
    change_color(color1)
    xr = x + width
    draw_text(xr - 40, y, 42, line_height, percentage, 2)
  end
end
Feel free to complain if it doesn't work or if it doesn't match your imagination but please be more specific in that case.
(dang it, ninja'd by a milisecond)
Ruby:
class Window_MenuStatus
  def draw_current_and_max_values(x, y, width, current, max, color1, _color2)
    percentage = "#{(current.fdiv(max) * 100).ceil}%"
    change_color(color1)
    xr = x + width
    draw_text(xr - 40, y, 42, line_height, percentage, 2)
  end
end
Feel free to complain if it doesn't work or if it doesn't match your imagination but please be more specific in that case.
1612544279170.png

sorry, it didnt seem to work on my end... :0(
@gstv87: You didn't have to delete it. My code is mostly the default code too. Who knows if the sizes and alignment is correct. Btw. I hate that squeezed text misfeature.

Also btw. Float#to_i always rounds down. If you have 0% health (for example, when current=2 and max=562) but are still alive, are you a zombie?

@whotfisjojo: I guess you have an actor with zero max. MP or morale, correct? It should show as 0% now.
Ruby:
class Window_MenuStatus
  def draw_current_and_max_values(x, y, width, current, max, color1, _color2)
    change_color(color1)
    xr = x + width
    percentage = max.nonzero? ? (current.fdiv(max) * 100).ceil : 0
    draw_text(xr - 40, y, 42, line_height,"#{percentage}%", 2)
  end
end
im not quite sure i understand? if you are asking if one of the actor's is 0 hp- no their health is currently 100, but even so i would like for the script to still work 0 hp or not
If you have 0% health (for example, when but are still alive, are you a zombie?
well... that's what happens with percentages when the numbers are large.
in my early edits of the code, I had situations with 1 HP, 0 HP, 0.1%, 0%, etc... with the corresponding errors when calculating damage, resurrections and the like.
wow, it's really looking great!
1612545087591.png

however i cannot control the amount of hp/mp through events...
hp is stuck at 100% while mp is stuck 0%
i would love to be able to change the amount through Change MP & Change HP
please & thank you :0)
im not quite sure i understand? if you are asking if one of the actor's is 0 hp- no their health is currently 100, but even so i would like for the script to still work 0 hp or not
Small misunderstanding? The question wasn't for you. It was a bug in @gstv87 code but I believe we both had the NaN bug. While dividing by zero is actually possible it usually doesn't end well further down the road.

If Change HP/MP doesn't work (for me it does), please post current/max HP/MP for every actor as well as the event commands.
an increase of 1 over a maximum of 100 with a relative of 100 over 100, always yields 100%
100/100, 100%
101/101, still 100%.
i have set the max hp/mp for one class to be 100 & all my actors are all the same one class
(im not going to be using the battling system)
Spoiler: hp
1612546907971.png
Spoiler: mp
1612546888343.png
1612546579831.png

i am not trying to go above 100 or below 0
but i cannot go below 100 for the hp(like 50%)
and i cannot go above 0 for the mp
its just like theyre stuck at those numbers
being able to control the amount of hp/mp is very important to the gameplay
Your description doesn't match your screenshots. It won't work if MHP is 1 because this means your HP will either be 0 or 1 (0% or 100%). And if knockout isn't allowed it'll stay at 1 (100%).
i am so so sorry!! you are completely right! it is set low!
1612548125323.png

ive reset the hp/mp to 100 each and it works like a charm!!
thanks again for your help!! have a wonderful day cremnophobia!! :0) <3

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/hp-mp-number-into-percentage.133066/