Decimal Currency

● ARCHIVED · READ-ONLY
Started by sutorumie 9 posts View original ↗
  1. Would it be possible to change the way money is displayed from, say, 1,000G to $10.00 ? Preferrably so it displays on the menu screen and the shop screen. There were a few scriplets like this for VXAce (here's one), to make it so the last two digits are behind a period and the currency symbol is displayed to the left of the numbers. I suppose this would also mean I'd need to replace the icon with text, but I could also just draw a dollar sign as an icon, so, that's not a big deal.

    I've looked all over and attempted to do it myself but I don't quite understand javascript yet and I haven't found anything by googling or searching these forums.


    2il287c.png
  2. 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);
    };

    })();
  3. This works pretty well, thank you !<3

    Would it be possible to get the shopbuy / shopsell windows to display in decimals, and for items to cost less than a dollar (ex. $0.50)? Maybe a notetag or something?

    EDIT: After doing some more testing I've discovered that this script interferes with my ability to work with other variables unrelated to gold variables. More specifically, I'm using Orange Time System and the variable to change time (in minutes, haven't tested hours or days yet but I have no reason to believe it's any different) no longer works with this plugin installed. It just resets to the old value from before I tried to change it. I'm assuming this has something to do with the Game_Variables.prototype.setValue function but I don't know what to do with it because I don't even really know what it's doing ?
  4. Bump !
  5. 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));
    };

    })();
  6. Ah, perfect ! Although I actually can't get a currency unit to display in shopbuy / shopsell at all? Is there supposed to be one there? It doesn't show in a new project either, and I've been trying to write one in but it doesn't seem to work orz

    Oh, also I added this onto the end to have the script affect Window_ShopNumber as well:

    Window_ShopNumber
    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);
    };

    35i11d4.png
    2chu7hj.png
  7. 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.
  8. AH okay . Thank you for all your help !
  9. 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.