Gold displaying as Dollars and Cents?

Status
Not open for further replies.

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,185
Reaction score
1,440
First Language
English
Primarily Uses
Other
Is there a way to make gold display in the gold window, in shops, and battle reward as something like $10.50 instead of 1050G?
 

tale

Volunteer
Veteran
Joined
Dec 16, 2016
Messages
709
Reaction score
1,194
First Language
English
Primarily Uses
N/A
Plugin in the attachment is based on this post- https://forums.rpgmakerweb.com/index.php?threads/decimal-currency.98209/#post-888095
Also a small add-on at the end of the script that affect Window_ShopNumber as well by sutorumie.

Note: you have to change the currency manually from the database under System.

If someone wants to modify the code, here's a sample. It doesn't cover battle reward yet.
Code:
(function() {

Game_Party.prototype.gainGold = function(amount) {
this._gold = this._gold + amount //parseFloat(Math.round(amount * 100) / 100).toFixed(2);
};

Game_Party.prototype.gold = function() {
return parseFloat(Math.round(this._gold * 100) / 100).toFixed(2);
};

Window_Gold.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
this.drawCurrencyValue(this.currencyUnit(), this.value(), x, 0, width);
};

Scene_Shop.prototype.buyingPrice = function() {
if (this._item.meta.price) {
return this._item.meta.price;
} else {
return this._buyWindow.price(this._item);
}

};

Scene_Shop.prototype.money = function() {
return Number(this._goldWindow.value());
};

Scene_Shop.prototype.sellingPrice = function() {
if (this._item.meta.price) {
return this._item.meta.price;
} else {
return this._buyWindow.price(this._item);
}
};

Window_ShopBuy.prototype.price = function(item) {
if (item.meta.price) {
return item.meta.price;
} else {
return this._price[this._data.indexOf(item)] || 0;
}

};

Window_ShopBuy.prototype.isEnabled = function(item) {
return (item && this.price(item) <= this._money &&
!$gameParty.hasMaxItems(item));
};

})();

Window_ShopNumber.prototype.drawTotalPrice = function() {
var total = parseFloat(((this._price * 100) * this._number) / 100).toFixed(2);
var width = this.contentsWidth() - this.textPadding();
this.drawCurrencyValue(this._currencyUnit, total, 0, this.priceY(), width);
};
 

Attachments

JtheDuelist

Your Friendly Nieghborhood Stygian Zinogre
Veteran
Joined
Dec 9, 2017
Messages
1,185
Reaction score
1,440
First Language
English
Primarily Uses
Other
Hmm, that works, but outside of shops, it is displaying as 0.00$ instead of $0.00, @tale
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA

I've moved this thread to Plugin Requests. Please be sure to post your threads in the correct forum next time. Thank you.


Might need an additional mini-plugin to get it working outside of Shops.
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
147
Reaction score
166
First Language
Danish
Primarily Uses
RMMV
Hi, I wrote you a new plugin as I didn't really like the one you were offered.
If you encounter any problems with it feel free to message me :)

Code:
//=============================================================================
// Decimal Dollar
// MRP_DecimalDollar.js
// By Magnus0808 || Magnus Rubin Peterson
//=============================================================================

/*:
 * @plugindesc Changes the way gold is displayed.
 * @author Magnus0808
 *
 * @help This plugin changes the way gold is displayed. With this it is displayed
 * as decimal numbers dollar style. This means that 100$ will be displayed as
 * $1.00.
 *
 * @param Always Show Decimal
 * @type boolean
 * @desc If true then exactly $1 will be displayed as $1.00
 * @default true
 */

 var Imported = Imported || {};
 Imported.MRP_DecimalDollar = true;
 
 var MRP = MRP || {};
 MRP.DecimalDollar = MRP.DecimalDollar ||{};
 
(function() {
    MRP.DecimalDollar.parameters = PluginManager.parameters('MRP_DecimalDollar');;
    MRP.DecimalDollar.alwaysShowDecimal = (String(MRP.DecimalDollar.parameters['Always Show Decimal']) == "true");

    MRP.DecimalDollar.convertGold = function(gold) {
        var decimal = gold%100 < 10 ? "0" + gold%100 : gold%100;
        if(!MRP.DecimalDollar.alwaysShowDecimal && Number(decimal) == 0) {
            return Math.floor(gold/100);
        }
        return Math.floor(gold/100) + "." + decimal
    }
    
    Window_Base.prototype.drawCurrencyValue = function(value, unit, x, y, width) {
        value = MRP.DecimalDollar.convertGold(value);
        var valueWidth = Math.min(80, this.textWidth(value));
        this.changeTextColor(this.systemColor());
        this.drawText(unit, x, y, width - valueWidth - 6, 'right');
        this.resetTextColor();
        this.drawText(value, x, y, width, 'right');
    };
    
    BattleManager.displayGold = function() {
        var gold = this._rewards.gold;
        if (gold > 0) {
            $gameMessage.add('\\.' + TextManager.obtainGold.format(MRP.DecimalDollar.convertGold(gold)));
        }
    };
    
    Window_ShopBuy.prototype.drawItem = function(index) {
        var item = this._data[index];
        var rect = this.itemRect(index);
        var priceWidth = 96;
        rect.width -= this.textPadding();
        this.changePaintOpacity(this.isEnabled(item));
        this.drawItemName(item, rect.x, rect.y, rect.width - priceWidth);
        this.drawText(MRP.DecimalDollar.convertGold(this.price(item)), rect.x + rect.width - priceWidth,
                      rect.y, priceWidth, 'right');
        this.changePaintOpacity(true);
};
    
})();
 

Attachments

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,354
Reaction score
8,533
First Language
English
Primarily Uses
RMMV

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top