MZ (Visustella MainMenuCore/SkillLearnSystem) Display an actor's Ability Points under their gauges on the main menu?

Hi there, a request regarding Visustella's Main Menu Core and Skill Learn System.

I'm using the MainMenuCore's portrait list style, and I want to display the actor's current Ability Points (SkillLearnSystem) under the regular gauges.

Here's a mock-up of what I'm talking about:

Example.png


Actor 1 is how a character is currently displayed on the main menu, Actor 2 is what I'm picturing.

In the plugin settings for MainMenuCore, I see a section for List Style Settings:

Mainmenucore.png


I do not know JavaScript, but looking at the code under JS: Portrait, I see the section ends with the regular gauges being created.

Portraitjs.png


This makes think that something can be added here to call and display an actor's AP. Would anybody be willing to work out the script to do so?

Separate but related request, I'm also interested in the script to write an actor's Ability Points to a variable. I intend to use this to synchronize multiple actor's Ability Point values. I understand the game would need to constantly be writing the Actor's AP values to the corresponding variables to keep it accurate.

Thanks for reading. Over the past year or so, I've been able to put together most of my would-be requests by lurking the forums and consulting the script call list, but this one's a pretty specific ask.
Setup with default sample project in portrait style:
Firstly, you will need to change the total height from 4.5 to 5, to allow enough space
Code:
// Make Constants
const lineHeight = this.lineHeight();
const gaugeLineHeight = this.gaugeLineHeight();
const totalHeight = (lineHeight * 5) + (gaugeLineHeight * ($dataSystem.optDisplayTp ? 3 : 2));

then, under draw gauges:
Code:
sy += gaugeLineHeight; // Drop Y position
this.contents.fontFace = 'rmmz-numberfont'; // Change font to match gauges(number font)
this.contents.fontSize = 20; // Change font size closer to gauge size
actor.gainAbilityPoints(0, actor.currentClass().id); // Points don't get loaded into the ability points object until you load the skill scene and learn window and return undefined. Adding this line will circumvent this by adding 0 points into current class.
this.drawText(TextManager.abilityPointsAbbr, sx, sy, sw - 100, 'left') // Draw ability points, right-aligned, abbriviation(VisuMZ_2_SkillLearnSystem > Ability Points Settings > Abbreviated Text). Adjust width (sw) +/- to suit your needs.
this.drawText(actor._abilityPoints[actor.currentClass().id], sx, sy, sw - 120, 'right') // Draw the points, right-aligned. Adjust width (sw) +/- to suit your needs.

1725805465921.png


Adjust to your needs, enjoy!
Hey, thanks for the response!

I tried it it out, and it initially didn't work. I experimented a bit and figured out it's because I've got "share ability points between classes" enabled under SkillLearnSystem's plugin parameters. I modified the fourth line you provided under draw gauges to remove the reference to a specific class:

Code:
actor.gainAbilityPoints(0);

And that line seems to function as the workaround you suggested, as AP displays just fine when share ability points is disabled.

While share ability points is enabled, however, removing the same bit of code from the sixth line under draw gauges only returns undefined:

Code:
//Before
this.drawText(actor._abilityPoints[actor.currentClass().id], sx, sy, sw - 120, 'right')

//After
this.drawText(actor._abilityPoints, sx, sy, sw - 120, 'right')

I tried to brute force it with a number of variations, but I didn't have any luck. Could you tell me how fix it?

By the way, I appreciate the explanation you included with every line. Really helped me understand the steps.
The ability points class ID is set to 0 when shared.

Not much modification is needed.
Code:
sy += gaugeLineHeight;
this.contents.fontSize = 22;
actor.gainAbilityPoints(0, 0); // Class is set to 0
this.drawText(TextManager.abilityPointsAbbr, sx, sy, sw, 'left')
this.contents.fontFace = 'rmmz-numberfont';
this.drawText(actor._abilityPoints[0], sx, sy, sw - 120, 'right') // Class is set to 0
Ah, I was so close on a few of my attempts.

Works beautifully. Thanks for the help, and you're the best!
Is possible replace the AP text to add a icon?

Original thread: https://forums.rpgmakerweb.com/threads/visustella-mainmenucore-skilllearnsystem-display-an-actors-ability-points-under-their-gauges-on-the-main-menu.171719/