[VX ACE] HP not updating

Hello!

I've just gotten into scripting with RGSS, and I'm having a bit of trouble with updating my variables in real-time.  I think it may be how i'm using the script rather than the script itself, but I'm not sure.  Using update has worked for my other scripts, but not this one.

class Scene_HUD < Scene_Base def start @act1_stat_win = Window_Stat.new(0, 0, 200, 55, 1) @act1_stat_win.opacity = 75 end endclass Window_Stat < Window_Base def initialize(x, y, width, height, window_num) super(x, y, width, height) @window_num = window_num refresh end def update super refresh end def refresh contents.clear @party = $game_party.members draw_actor_graphic(@party[@window_num - 1], 32, 32) draw_text(50, 10, 50, line_height, @party[@window_num - 1].hp) end endAnd when I'm putting it up, I start an instance of Scene_HUD with a Script Event.

@Stat_Window = Scene_HUD.new@Stat_Window.startCan someone tell me what I'm doing wrong to not have the HP update?

EDIT:

Well, I finally managed to do it the manual way.  That is, I hunted down the methods that took care of changing player HP (damage and recovery) and called my update method in my Scene_HUD instance from there.  It works, but I'm fairly sure there is an easier way to do it.  Plus, I don't like editing the default scripts if I can create my own classes and just use existing classes and methods to do what I want.

I would still appreciate any help with doing it an easier way.  Also, if someone could point me to a place that has all the global variables, classes, and methods along with their required arguments that would be very helpful.  I found a post on these forums that had a some, but was missing a lot of things.
Hello,

The better way would to have the HUD window in the Scene_Map class.

HUD's are supposed to be on map screens aren't they?

At least that's what I thought when I made my HUD script (yet unreleased)

And for the help about Ruby, well, enter the script editor and click "Help" in the down right corner.

It will open help with Windows Help Viewer.

Windows Help Viewer has also a very great option for search. Try it!

Also, for the editing of default scripts... Did you ever hear about 'alias'?

Well, the basics of alias are that it 'copies' one function to another.

Example :

class Game_Map alias this_is_the_aliased_start_method start def start this_is_the_aliased_start_method # Put your code here endendAnd that's how scripters do things 🙂 I would recommend you some YT tutorials, but I don't want to advertise anybody here.
Scene classes are not exactly meant to be used like that.


Basically, you don't need that SceneHUD class at all.


Also, do not ever put any refresh method into an update method without a condition which prevents it to refresh on every frame, unless you want to kill your FPS. And FPS is greatly pumped on Scene_Map already, doing what you did would reduce it even further.


You only need to redraw your HUD if the HP or face of the actor is changed, so make a condition based on that.


Basically, Admiralac just wrote a better method for the window initialization, except that he wrote Game_Map instead of Scene_Map for the class name in the code example, but that is probably a late night typo. 😀

Spoiler
@Admiralac
I understand and get your signature even if I don't like those type of letters, lol. 😀
Thanks to the both of you.

@ Admiralac:  I did not know about the alias, but now that I do, I'm going to be making use of it 🙂 .  I'm still trying to get a feel for which classes are responsible for doing what, so you are probably right about the proper place for windows to make a HUD.

@Sixth:  I did not think of what it would do to my frame rate, and I probably would never have if you hadn't pointed it out to me, so thanks for that.  I've found some tutorials online while searching around when I was waiting for a reply to this post.  Don't know why searching tutorial, Ruby, and RPG Maker doesn't give any good results, but when I searched RGSS3, I got a lot of them.

Original thread: https://forums.rpgmakerweb.com/threads/vx-ace-hp-not-updating.43075/