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,186
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
807
Reaction score
1,357
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,186
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,795
Reaction score
5,351
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
149
Reaction score
173
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,551
Reaction score
8,628
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

I went to sleep at 3 am because of my anxiety. Set up my alarm for 7 am so that I could have sasagues for breakfast and do morning routine before lessons starts at 8 am. I knew I wouldn't be able to sleep even after my lessons finished because I have to visit my grandparents today I was sad bc I was really tired. Thats when I realised. My lesson starts at 9 am. I could get one extra hour of sleep if I didnt forget it
Found another copied song in MV's OST

Forum statistics

Threads
107,556
Messages
1,030,524
Members
139,672
Latest member
WDRS
Top