MZ Replace TP bar with EXP bar in main menu

Hi all, I am using the Visustella main menu core plugin and this is what the code looks like for what the main menu is being asked to show for the portion of information that I am trying to show.

JavaScript:
// Place Gauges
sx += 180;
sy = rect.y + ((rect.height - (gaugeLineHeight * ($dataSystem.optDisplayTp ? 3 : 2))) / 2) - 2;
this.placeGauge(actor, "hp", sx, sy);
this.placeGauge(actor, "mp", sx, sy + gaugeLineHeight);
if ($dataSystem.optDisplayTp) this.placeGauge(actor, "tp", sx, sy + (gaugeLineHeight * 2));
sx += 160;

I already tried to replace the letters tp wit xp and exp but that didn't work. I'm no expert in Javascript unfortunately.

I want to change it show that is shows an exp bar for reaching the next level instead of the tp bar. Can anyone help me please?
2021-05-04 (4).png
Bump
Is that code in the VisuStella plugin? You'd have to search for the placeGauge function to see if it has the option to display experience, it may have to be coded separately.

You've already read the plugin documentation to see if it says anything about this?
I've looked through and read everything in their online documentation and the plugin options itself. To the best of my knowledge the rpg maker engine itself doesn't provide an exp bar by default either so I am thinking some js coding will need to be build.
I Googled "RPG Maker exp gauge" and found this plugin.

It's for MV, so it won't work with your VisuStella plugin, but you can read the code and it should be pretty much the same.
HEEEEY!!! We're on the same page, looks like we've been looking at the same thing haha. I downloaded the js and since I am using MZ I forced it into the fossil program to work with the MZ engine but it doesn't seem to be working unfortunately 🙁. I won't give up.
Mz's default gauge placement is remarkably nonflexible.


I wrote this for status menu core compatibility, it should work for your purpose as well.
Code:
	Fossil.AddSprite_GaugeCurrentValueXP= Sprite_Gauge.prototype.currentValue;

		
	Sprite_Gauge.prototype.currentValue = function() 
	{
		//if we see a number assume it's a parameter id
		if(typeof(this._statusType)=='number')
		{
			//and return it
			return SceneManager._scene._infoWindow._actor.param(this._statusType) //Math.round(SceneManager._scene._infoWindow.calcParamRate(this._statusType)*this._largestParam)
		}
		if (this._battler) 
		{
			switch (this._statusType) 
			{
				case "xp":
					return Math.floor(100*Window_StatusInfo.prototype.actorCurrentExpRate(this._battler));
				case "xp2":
					return Math.floor(100*Window_StatusInfo.prototype.actorExpRate(this._battler));
			}
		}
		return Fossil.AddSprite_GaugeCurrentValueXP.call(this)
	};

Try replacing 'mp' with 'xp' again after adding that function.

Code:
this.placeGauge(actor, "xp", sx, sy + gaugeLineHeight);

EDIT: wait a sec that relies on yanfly's code to calcualte xp for next level. Give me a sec


EDIT2:
checked RMMZ_objects. the functions we want to invoke are probably the next level xp and the current exp
Code:
Game_Actor.prototype.currentExp = function() {
    return this._exp[this._classId];
};

Game_Actor.prototype.nextLevelExp = function() {
    return this.expForLevel(this._level + 1);
};

so to avoid using yanfly's code, just divide one by the other and do something like this

Code:
	var AddSprite_GaugeCurrentValueXP= Sprite_Gauge.prototype.currentValue;

		
	Sprite_Gauge.prototype.currentValue = function() 
	{

		if (this._battler) 
		{
			switch (this._statusType) 
			{
				case "xp":
					return this._battler.currentExp();
			}
		}
		return AddSprite_GaugeCurrentValueXP.call(this)
	};


	var AddSprite_GaugeCurrentMaxValueXP =Sprite_Gauge.prototype.currentMaxValue;
	Sprite_Gauge.prototype.currentMaxValue = function() 
	{
		if (this._battler) 
		{

			switch (this._statusType) 
			{
				case "xp":
					return this._battler.nextLevelExp();
			}
		}
		return AddSprite_GaugeCurrentMaxValueXP.call(this);
	};
Ohhh, that was a strong tease hahaha, I am super super glad for your help though. I shall be patient. I've updated to the latest fossil plugin too if that helps.

Edit: Will I add this code as a plugin or should I paste it as part of the code in my main post? sorry for my questions ^^;
yeah try adding
Code:
	var AddSprite_GaugeCurrentValueXP= Sprite_Gauge.prototype.currentValue;

		
	Sprite_Gauge.prototype.currentValue = function() 
	{

		if (this._battler) 
		{
			switch (this._statusType) 
			{
				case "xp":
					return this._battler.currentExp();
			}
		}
		return AddSprite_GaugeCurrentValueXP.call(this)
	};


	var AddSprite_GaugeCurrentMaxValueXP =Sprite_Gauge.prototype.currentMaxValue;
	Sprite_Gauge.prototype.currentMaxValue = function() 
	{
		if (this._battler) 
		{

			switch (this._statusType) 
			{
				case "xp":
					return this._battler.nextLevelExp();
			}
		}
		return AddSprite_GaugeCurrentMaxValueXP.call(this);
	};

as a plugin, then change the mp gauge to xp, and we'll see where I typoed
My brooooo, I see an exp gauge 😀!!!
I've tested it an it's working as intended. The only issue is
the exp bar never goes below half because you always retain the exp that you've already earned I am guessing?
Instead of going back to zero to begin the next level.
I don't think the visustella menu is respecting the fact that it's an exp bar either. The words aren't next to it saying XP.
I might have to place the plugin in a different order.
2021-05-07.png
okay, try this:

for the maximum, use .nextLevelExp() minus .currentLevelExp()
for the current use .currentExp() minus .currentLevelExp()

and to add the label:
Code:
	var AddSprite_GaugeLabelXP=Sprite_Gauge.prototype.label;
	Sprite_Gauge.prototype.label = function() {
		switch (this._statusType) 
		{
			case "xp":
			case "xp2":
				return TextManager.expA 
		}
		return AddSprite_GaugeLabelXP.call(this);
	};
Mann, you're a life saver and I'm almost in tears. Thank you so much for your help 😀
The menu looks exactly as I wanted it in my head 😀!!

I am still trying to figure out where to place the

.nextLevelExp() minus .currentLevelExp()
.currentExp() minus .currentLevelExp()

but I'm already super greatful 😀!


2021-05-07 (2).png



EDIT: I wasn't able to figure to figure it out sorry :I.
with using
.nextLevelExp() minus .currentLevelExp()
.currentExp() minus .currentLevelExp()

2021-05-07 (3).png
I am still trying to figure out where to place the

.nextLevelExp() minus .currentLevelExp()
.currentExp() minus .currentLevelExp()


EDIT: I wasn't able to figure to figure it out sorry :I.
He told you where to put it in the code he already gave you. Replace return this._battler.currentExp(); with return this._battler.currentExp()-this._battler.currentLevelExp();
And, similarly, replace return this._battler.nextLevelExp(); with return this._battler.nextLevelExp()-this._battler.currentLevelExp();
THANK YOU SO MUCH!!!
You are both super amazing 😀!!!!

This thread has been solved 😀!

Original thread: https://forums.rpgmakerweb.com/threads/replace-tp-bar-with-exp-bar-in-main-menu.136200/