Problem with eventing a heath bar

**Edit: Problem Solved! You can close this thread now.**

So I use the easiest method of eventing a HUD health bar. Which is the picture zoom method. (basically I call a common event that displays two pictures, one for the HUD frame and the other the HP bar.

To calculate how the health bar is going to decrease, I use the following snippet

Code:
mhp = $game_party.members[0].mhp
hp = $game_party.members[0].hp
calculate = (hp * 100) / mhp
screen.pictures[2].move(0, 0, 0, calculate, 100, 255, 0, 30)

The problem? The x positioning! When the HP becomes too low, the HP bar just glitches out of the HUD box. And I have no idea how to fix this.
When full, it looks like this : )
upload_2019-9-16_12-6-58.png

But when empty it does this : (
upload_2019-9-16_12-6-45.png


Any ideas?
I use SRD_HUDmaker plugin for it, which works probably better.
but using events, does the picture stays 0? or the you use 1 0 to much,
so you can try (if it doesn't make sense) to (0, 0, calculate, 100, 255, 0, 30)

Im not really sure what the 3 zero's does, I know its x, y , ? .
I use SRD_HUDmaker plugin for it, which works probably better.
but using events, does the picture stays 0? or the you use 1 0 to much,
so you can try (if it doesn't make sense) to (0, 0, calculate, 100, 255, 0, 30)

Im not really sure what the 3 zero's does, I know its x, y , ? .

The code reads as follows: screen.pictures[ID].move(position (top left or center) , x, y, x zoom, y zoom, opacity, blend type, wait)

But that plugin you mentioned sounds interesting. Is it for VX ace (The maker I am using) because I can only find hud makers for MV which are in java and by extent completely useless to my project.
I just see yo uusing VXA, My bad, hud maker is only for MV, while its javascript, vxa use ruby so
making the hud work a bit slightly, I know I saw a tutorial for vxa based regarding HP bar.

Ima look if I can find that part, but it doesn't use scriptcall though, its just placed over.

also, if you using 1 member/1player, you can try $game_player.leader (idk if it does take that though) while its the same
as members[0].
but if its around the same in MV, you can try using () on the end of members, unless thats only javascripts.

Let me find something regarding your issue if i can find it, unless someone is faster than me 🙂
I just see yo uusing VXA, My bad, hud maker is only for MV, while its javascript, vxa use ruby so
making the hud work a bit slightly, I know I saw a tutorial for vxa based regarding HP bar.

Ima look if I can find that part, but it doesn't use scriptcall though, its just placed over.

also, if you using 1 member/1player, you can try $game_player.leader (idk if it does take that though) while its the same
as members[0].
but if its around the same in MV, you can try using () on the end of members, unless thats only javascripts.

Let me find something regarding your issue if i can find it, unless someone is faster than me 🙂

Well, I don't think how changing the syntax will help since my issue is with the x position not the syntax itself. And besides, MV and Ace use drastically different terms not just in java script but in the interperter so the only thing it would achieve would be crashing the game completely.

I am just asking if there is a way to fix the x position of the hp bar to move slightly to the right so it doesn't glitch through the hud frame...

amyway thank you for at least trying to help
Its not only that your Hp Bar is shown to far left, also it seems the Z Level has changed, that indicates that something with the Picture IDs got messed up.
Higher Picture Ids are shown ontop of Pictures with lower IDs.
I hope this helps.

Edit: Or can you show Pictures of the whole Eventpages involved.
did you follow this guide?
it also said not to stay from center image, so 0,0,0 would be in the far top left corner.

in case you follow this tutorial, there is a script said in it (idk if it works) for the snippets he said.
in case you did that, than I got no clue how to fix your issue. But it shouldn't happen that the x-position moved to the left though,
which is really weird.
Looking through your "move picture" code, it looks completely solid to me. I'm honestly not sure why it isn't working.

One other approach you could take, though it requires considerably more effort, would be to have a "display HP %' variable that slowly ticks down or up (toward the actual HP variable) after changing the HP variable, and to create like 20 different pictures each representing 5% increments of HP. Which picture to show would depend on the Display HP variable. You'd probably want to have a Switch to determine whether the graphic needs to keep recalculating every couple of frames (and set that switch OFF once the Display HP % is equal to the actual HP %), to keep performance smooth. One extra advantage of this approach is that you can make it so that only the red part of the bar will be shown as Sanity gets low, not a squished Red-Blue bar.

If you have trouble implementing this, quote me or @ me and let me know what eventing you tried and what behavior you're actually seeing.
Try this in your script call, open up the console window, in which value it started to break
Code:
100.times do |i|
  screen.pictures[2].move(0, 0, 0, 100 - i, 100, 255, 0, 30)
  p 100 - i
  Fiber.yield
end
Its not only that your Hp Bar is shown to far left, also it seems the Z Level has changed, that indicates that something with the Picture IDs got messed up.
Higher Picture Ids are shown ontop of Pictures with lower IDs.
I hope this helps.

Edit: Or can you show Pictures of the whole Eventpages involved.
You just gave me an idea. I think I know what to do. You see, I made the HP bar picture look like this
upload_2019-9-16_19-20-45.png

Whereas to avoid distortion, I should make it something like this and position it myself

upload_2019-9-16_19-21-36.png

It works like a charm now! No overlap, no warping beyond the Frame. Everything is as it should be. (And I learned my lesson to not always depend on the map dimentions for picture positioning...)
I wouldn't recommend that big size in png, but if you do, I would suggest to use tinypng to make the size of that png
smaller. but it can happen, it start from the far right instead of the HP bar itself.

but as long it works, it works, but its a little warning though =)

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/problem-with-eventing-a-heath-bar.113347/