MV Show gold max from Yanfly core?

Hey all,

So I decided on having a pretty low limit on gold so that the player will be encouraged to spend it rather than go over cap. However I want the cap to shown to players at the main menu so they are always aware what it is. I'm not really sure how to change this window how I want, however using script calls to change "Yanfly.Param.MaxGold" works easy enough. I think I need to fiddle with this in the rpg_windows.js, but so far my attempts have created either instant crashes, or prevented Yanfly's Core plugin from loading. I'm not sure anything in the Yanfly Core plugin actually touches this window, aside from the feature that swaps out the amount with "A lotta" when the number is too big.

In short, the main menu shows it as:
[current gold] [gold icon]
I want it to look like:
[current gold] / [max gold] [gold icon]
I made a plugin for you. I believe it will work. Place below all Yanfly plugins. For this plugin I set the the max value to 99999. You can change that or you can remove lines 3, 4, and 5. I only had that for testing purposes because default window is small.

The plugin is free for noncommercial and commercial use. Plugin can be edited and distributed. Credit for plugin is not required.

This plugin does not display the max gold in shops. This plugin overwrites Game_Party.prototype.maxGold, Window_Base.prototype.drawCurrencyValue, Window_Gold.prototype.refresh, and Window_Gold.prototype.value. Window_Gold.prototype.value is redundant and can be removed from plugin.

Window_Gold.prototype.maxValue is the only function I created for the plugin.

I hope this plugin works for you. Good luck 🙂

Spoiler: Current_and_Max_Gold_Display.js
// Save as Current_and_Max_Gold_Display.js Game_Party.prototype.maxGold = function() { return 99999; // You can change this value if you want :) }; Window_Base.prototype.drawCurrencyValue = function(value, maxValue, unit, x, y, width) { var unitWidth = Math.min(80, this.textWidth(unit)); this.resetTextColor(); this.drawText(value, x, y, width - unitWidth, 'left'); // Current gold display, left alignment this.drawText("/", x, y, width - unitWidth - 6, 'center'); // Displays /, center alignment this.drawText(maxValue, x, y, width - unitWidth, 'right'); // Max gold value display, right alignment this.changeTextColor(this.systemColor()); // Uses system color for text this.drawText(unit, x + width - unitWidth, y, unitWidth, 'right'); // Displays unit, which is normally G }; Window_Gold.prototype.refresh = function() { var x = this.textPadding(); var width = this.contents.width - this.textPadding() * 2; this.contents.clear(); this.drawCurrencyValue(this.value(), this.maxValue(), this.currencyUnit(), x, 0, width); }; // This function is used in Window_Gold.prototype.refresh function as this.value() Window_Gold.prototype.value = function() { return $gameParty.gold(); }; // This function is used in Window_Gold.prototype.refresh function as this.maxValue() Window_Gold.prototype.maxValue = function() { return $gameParty.maxGold(); }; //If you also want shop gold display then you will have to ask or add the functions yourself

TestMinMaxGoldDisplay.png
@Zeireth Outstanding, thank you!
1654795053088.png

I modified it a little bit. Using the Yanfly variable so I can change the value in events (for player upgrades). I also changed the unit text to an icon, and clumsily adjusted the values in the window since it seemed to be misaligned on my chosen resolution.
JavaScript:
// Save as Current_and_Max_Gold_Display.js

Game_Party.prototype.maxGold = function() {
    return Yanfly.Param.MaxGold; // You can change this value if you want :)
};

Window_Base.prototype.drawCurrencyValue = function(value, maxValue, unit, x, y, width) {
    var unitWidth = Math.min(80, this.textWidth(unit));
    this.resetTextColor();
    this.drawText(value, x, y, width - unitWidth, 'left');         // Current gold display, left alignment
    this.drawText(" / ", x, y, width - Window_Base._iconWidth - 8, 'center');                 // Displays /, center alignment
    this.drawText(maxValue, x, y, width - Window_Base._iconWidth - 8, 'right');     // Max gold value display, right alignment
    this.changeTextColor(this.systemColor());                            // Uses system color for text
    this.drawIcon(Yanfly.Icon.Gold, x + width - Window_Base._iconWidth, y + 2);    // Displays unit, which is normally G
};
Good job woootbm. I knew the code wouldn't fit with all resolutions. It looks nice. I am happy you took the initiative to edit the code to fit your project. I spent 15 minutes testing over and over trying to get the / perfectly centered, but then I realized I was trying to do that on a fresh project for testing purposes and it would not matter for other peoples projects.

I simply copied and pasted the default Window_Base.prototype.drawCurrencyValue function from rpg_windows.js in the js folder, and I put it into my script. I added 2 lines to that function as well. I hope my script was easy to read with all the comments. I have been looking for plugin requests to challenge myself and improve in javascript.

Time for lunch, I think I will have a bowl of pho.

Have a wonderful day, take care 🙂
@woootbm you can also make a if statement and a param to the a parameter,
which I use in my EC plugin, hat return to a parameter for max gold,
if CoreEngine is installed, it returned to that one.

easy use if you make a side game without that plugin, it still works 🙂
it's just an idea though.

EDIT:
here is a small snippet I made which can be usefull:

JavaScript:
Game_Party.prototype.maxGold = function() {
    if (Imported.YEP_CoreEngine) {
        return eval(Yanfly.Param.MaxGold);
    } else {
        return 200 ;//eval(PARAM NAME);
    }
};

this way, you can use it everywhere, even without YEP core plugin 🙂
if the 200 can be adjusted, set a variable there and you are good to go ^^
@woootbm you can also make a if statement and a param to the a parameter,
which I use in my EC plugin, hat return to a parameter for max gold,
if CoreEngine is installed, it returned to that one.

easy use if you make a side game without that plugin, it still works 🙂
it's just an idea though.

EDIT:
here is a small snippet I made which can be usefull:

JavaScript:
Game_Party.prototype.maxGold = function() {
    if (Imported.YEP_CoreEngine) {
        return eval(Yanfly.Param.MaxGold);
    } else {
        return 200 ;//eval(PARAM NAME);
    }
};

this way, you can use it everywhere, even without YEP core plugin 🙂
if the 200 can be adjusted, set a variable there and you are good to go ^^
If have been learning to avoid else as much as possible. We can use guard clauses or another function to avoid potential nesting which looks ugly and hard to read.

JavaScript:
Game_Party.prototype.maxGold = function() {
if (Imported.YEP_CoreEngine) {
return eval(Yanfly.Param.MaxGold);
}

return 200;
};
I dont know your way though or if that works.
I only know that way t make it work.

your way might work too, and can be cleaner as well, it might be ES6 code which
I dont know entirely as I use more the ES5 version =)

but if it works, why not ^^

Original thread: https://forums.rpgmakerweb.com/threads/show-gold-max-from-yanfly-core.148352/