This script will allow you to create decimal variables that you can use to add to the party's gold. For example you can set the decimal value at 7.98 and the party gold will display as $7.98 and will display the same way in a shop. Or if you just add a whole number value like 10, it will display as $10.00. To use the dollar sign you just put it in the currency section under system in the database. Just copy the code into notepad and save it as a .js file in your plugin folder and activate it in the editor. One thing it won't do is set shop prices with decimals.
(function() {
Game_Party.prototype.gold = function() {
return parseFloat(Math.round(this._gold * 100) / 100).toFixed(2);
};
Game_Variables.prototype.setValue = function(variableId, value) {
if (variableId > 0 && variableId < $dataSystem.variables.length) {
this._data[variableId] = value;
this.onChange();
}
};
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);
};
})();
Hi. Sorry. Got busy. I played around with it and seems to be working, though it's not perfect. Dollar sign is on the wrong side of buy and sell price, but you can use prices less than whole numbers. I took out the variable part. If you want to give the party other than whole number amounts of money you'll have to use the script call $gameParty.gainGold(0.99) or whatever amount. For item prices, use the note tag
<price: 0.99>
I haven't tested it extensively but I've done buys and sells of items and weapons of various decimal prices with no problems. Here's the new script.
(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));
};
})();
No, the currency unit only shows up on the number window, which you've fixed with the code you added. Glad it worked for you.
AH okay . Thank you for all your help !