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?
Gold displaying as Dollars and Cents?
JS Plugin RequestsPlugin 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.
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);
};
Hmm, that works, but outside of shops, it is displaying as 0.00$ instead of $0.00, @tale
Moved to: Plugin Requests
Might need an additional mini-plugin to get it working outside of Shops.
Might need an additional mini-plugin to get it working outside of Shops.
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 🙂
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);
};
})();
@Magnus0808 This was exactly what I needed! Many, many thanks!
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.
Original thread: https://forums.rpgmakerweb.com/threads/gold-displaying-as-dollars-and-cents.111388/