Draw Current and Max Value

Hello,

I'm a total script newbie, the best I can do are little edits here and there by looking at what others did and recreating it the best I can do. Just starting to learn the basics a little bit.

Right now I'm trying to display a hp gauge that is supposed to show the current hp number as a text, too.

I have this part of the script for that:

draw_current_and_max_values(X-75, Y-2, 120, @actor.hp, @actor.mhp,hp_color(@actor), normal_color);This shows the max value of hp, too. Like this: 45/50. But what if I only want to display the current value? Is there a way to do this?
That is where you CALL the function in Window_Base to draw the current and maximum values. Look at the function IN Window_Base to see what it does:

def draw_current_and_max_values(x, y, width, current, max, color1, color2) change_color(color1) xr = x + width if width < 96 draw_text(xr - 40, y, 42, line_height, current, 2) else draw_text(xr - 92, y, 42, line_height, current, 2) change_color(color2) draw_text(xr - 52, y, 12, line_height, "/", 2) draw_text(xr - 42, y, 42, line_height, max, 2) end endSo, if the width you pass in is less than 96, it will only draw the current amount, not the /max addition.You have a couple of options, depending on your requirements.

- You can always pass in a width of 95 or lower, so it only ever draws the current amount

- If you want the width to be larger than 96, but you only EVER want the current amount to be shown (for hp, mp AND tp) every time it's written, you could just comment out the if/else/end statements, and everything between the else/end statements, so only the first draw_text is called (after the colour change and calculating xr)

- If you only want to draw just the current amount sometimes, but other times show current AND max, you'll have to make a copy of that method in Window_Base and rename it, keep the first two lines (change colour and calculate xr), keep the first draw_text call, and delete the if/else/end statements and everything between the else/end statements - so you're creating a second function that will JUST draw the current amount, and call that new function instead.
Thanks for the fast answer ^^

I want the third version. Here is the code I did:

def draw_current_values(x, y, width, current, color1) change_color(color1) xr = x + width draw_text(xr - 40, y, 42, line_height, current, 2) endI wrote in a new section below Materials. And it worked! So happy 🙂

Thank you very much for taking the time and explaining this to me.
Awesome 🙂


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/draw-current-and-max-value.19593/