MZ HUD Maker Ultra [FREE VERSION] EXP Gauge

Hello! As stated in the title I am using Hud Maker Ultra and I am having difficulty creating an Experience gauge in my HUD. I am adding two images (one of the actual HUD and the other is the settings for the XP gauge). Under The Gauge Value input I have my Party Members Experience which is a possible value in the properties dropdown. However for Gauge Maximum there are no options to select for XP needed until the next level. In the second image you can see the beginning of the code that I am trying to use to get my HUD to use the number of XP needed for the next level but the full version is:

JavaScript:
$gameParty.members()[0].nextRequiredExp()

But when running the playtest the gauge shows but empty and stays empty. I am using Party Member as opposed to Actor only because the same code will be implemented on my battle HUD which all runs on Party. If anyone has an idea for the code to enter into the Gauge Max I will gladly try it and see if it works.

I found a thread on here with code but it was specifically MV and while I wasn't sure if they would work with MZ I tried displaying text where the text was the code provided and no text showed during playtest. I figured that if I could get the two text strings to show to show the values in text then they should work with the gauge and if not I'd just do a text XP/NeededXP but the text just shows blank. I greatly appreciate any input!


HUD.png
Gauge.png
Hmmm, in your pic the gauge isn't empty, it's full? If you have a lot of total experience, it can be bigger than exp needed for next level, so the gauge is always full. I think it should be something like (replace 'actor' with correct reference):

gauge value: actor.currentExp() - actor.currentLevelExp()
gauge maximum: actor.nextLevelExp() - actor.currentLevelExp()
I appreciate the feedback and after a couple hours of work (as I worked on both the map and battle HUDS) I was able to get it to work for both and I wanted to post my solution in case anyone else ever could use the info and found their way to this thread but I didn't want to get in trouble for double posting so I am extra glad that you replied haha I genuinely do appreciate your efforts! I will supply the codes and an explanation below each. I cannot promise that this is THE most elegant way of coding. And if your Max value is correct it is less steps than I employed but mine definitely performs correctly.

And as for the gauge looking full that is because the screenshot is of the editor which will appear as full so that you can see how the two color (for gradient) choices will look. But when playtesting the gauges shown only the gauge background color that it shows when it is completely empty.

MAP HUD - Gauge Value
JavaScript:
currentXP = $gameActors.actor(1).currentExp();
return currentXP;
Fairly straightforward. This sets the character's current total earned XP to a variable which is necessary to RETURN so the plugin can use it. Next Step is a little more complex.

MAP HUD - Maximum Value
JavaScript:
currentLVL = $gameActors.actor(1).level;
nextLVL = currentLVL + 1;
maxXP = $gameActors.actor(1).expForLevel(nextLVL);
return maxXP;
Overall what I am achieving is getting the total amount of XP required to reach the player's next level. The first line sets the character's current level number to a variable. The second line is obviously increasing the character's level by one because that is the level whose amount of XP is needed. The third line uses the second line's variable to set the total XP needed to reach the next level so the fourth line can RETURN a value that's usable by the plugin. This is more verbose but unless someone offers a solution that requires enough less processing power to make a noticeable difference, this works for me.

For Battle Hud they are quite the same except we have to deal with the party because there will be more displays to show (4 instead of 1). I will still show the full code but will only explain the first/new line.

BATTLE HUD - Gauge Value
JavaScript:
actorID = $gameParty.battleMembers()[0].actorId();

currentXP = $gameActors.actor(actorID).currentExp();
return currentXP;
The new line at the top is needed to get the Actor ID # as I knew what the ID was for the MAP and of course I could have used the same code as the MAP HUD for one of the character's displays because that character will always be leading the party. This line sets the character ID of the battle member defined to a variable that can be used to get the Current XP from the actor. Using battleMembers as I want to show HUD displays only for party members taking place in a battle as at during some battles it is possible to have followers in my game. Simply increase increase the battleMembers index number (from 0 to 1, 2 and 3) for the experience gauge in the display for each party member involved in the battle.

BATTLE HUD - Max Value
JavaScript:
actorID = $gameParty.battleMembers()[0].actorId();

currentLVL = $gameActors.actor(actorID).level;
nextLVL = currentLVL + 1;
maxXP = $gameActors.actor(actorID).expForLevel(nextLVL);
return maxXP;

Perhaps this will help someone. If someone offers a solution that uses calculations that will make a noticeable difference in processing speed then I can edit my codes above. But this solution works exactly as intended so otherwise I would consider this to be solved :rheh:

Original thread: https://forums.rpgmakerweb.com/threads/hud-maker-ultra-free-version-exp-gauge.178668/