Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

How to change by script the Currency Unit, please..?

Dad3353

Praised Adventurer
I'm trying to incorporate a dual Currency into my Game, but have some slight difficulties. The first is in changing the default \G value from 'Gold' in the Database to 'Quartz', for instance. I've been using the script call $dataSystem.currencyUnit=="Quartz", but when I display using \G, I still get 'Gold'. What have I overlooked, please..?

Edit: I found my mistake; it's the "==" that is wrong, sometimes, it should be "=", sometimes. One day I will understand why this syntax stuff is made so confusingly (but not today..! ;-) )
 
Last edited:

LTN Games

Master Mind
Resource Team
Xy$
0.01
== and === are for comparing values and types. = is to set a value. Hope that clears things up, also its not often you use == to compare moSt of the time it's ===. Id explain more but you will learn it all on your adventures into javascript.
 

Dad3353

Praised Adventurer
...you will learn it all on your adventures into javascript.
Begone, get thee hence, trouble me not with your suave siren voices..! I've recently retired from a long career in IT; the less I see and here of this Dark Art, the happier I remain..!
After ASM for 68K, C++, most of the rainbow of BASIC flavours, several 'proprietary' languages, SQL and more, I think I've done enough damage to the few grey cells that are now left. I'll doubtless have to dabble occasionally (as is the case in point...) but I'm certainly not looking to start all that again. When I get stuck, I'll ask the (hopefully...) pertinent questions here and try hard to follow the replies; no more, please..! Have pity..!
Thanks just the same, by the way; I'll doubtless be back with another schoolboy dumb question shortly. Patience will be required in bucket-loads. ;-)
 
TextManager sets the currency unit based on whatever text you've set for it in the Database.

(I started doing this in Otherworld.)

JavaScript:
var _alias__Window_Base_convertEscapeChars_Ecd = Window_Base.prototype.convertEscapeCharacters;
    Window_Base.prototype.convertEscapeCharacters = function(text) {
      var text = _alias__Window_Base_convertEscapeChars_Ecd.call(this, text);
       text = text.replace(/\x1bCC\[(\d+)\]/gi, function() {
           return this.change_currency(parseInt(arguments[1]));
       }.bind(this));
       return text;
    };

    Window_Base.prototype.change_currency = function(value) {
        return value === 0 ? cv = TextManager.currencyUnit : cv = 'Quartz';
        //cv;
    }

EDIT: Code was working, now it's not (removed for now).

Use /G for the default gold display. Use /CC[0] for the default also, but /CC[1] (or greater) to display "Quartz".
 
Last edited:

Dad3353

Praised Adventurer
Thanks for all the replies and ideas; I came across the tutorial 'Multiple Currencies' by TheUnproPro...
Multiple Currencies ...
... which covers my needs nicely, with a couple of tiny tweaks. It was my errors of transcription from his video that prompted this topic; it's all working now as it should, and I've learned a fair bit in the process. It's all win here, eh..? ;-)
 
The code I'd posted originally was from my NON working version. And now I can't find my working copy! But the main thing is you found a resolution. And so did I (found the working one). :)
 
Last edited:
Top