How would you approach In game multiple currencies conversion

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Hi

I am developping a plugin and I am kinda pretty rusty

So what I want to develop is a multiple currency system where the user can add more than just gold

so far we could though well just do an array and it's fine.

The bigger problem is the currency conversion

So let's separate the idea.

if 1 gold = 100 silver and 1000 copper
but that 1 silver = 100 copper.


It could be ideal to just let the user to enter manually each value but the problem is Now : the interface of the plugin manager doesn't let the user take two param and interact with each other

so how would you approach this math problem? or a way to make that you can cross convert currencies while letting the user add the amount of currencies they want?

wouldn't it be 'exponential?'

thank you for your further answer
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,895
Reaction score
1,029
First Language
Dutch
Primarily Uses
RMMV
there is one of this for vx / vx ace version, but you have also YEP_MoreCurrency, which allow this kind of this.

the bad thing (in my opinion) is that it need the shop core to work, but there isn't a seperate one.
if you know the MoreCurrency plugin of yanfly, you can make it so, you can input any kind of currency (multiple)
so you can do gold, silver, copper, ruby, diamonds etc etc.

but Idk how to handly this kind. I know you can event the big bunch, but plugin would be much nicer though.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Hum to be honest the thing was for a plugin not for event.

but if yanfly already did it I will focus another script then
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
Don't configure the relationship between every currency, for every currency you add, it would add (N-1) additional "relationships" where N is the total number of currencies.

Instead, each new currency would configure 1 value that's reference to a central currency. The central currency would never be given to a player, but you can use maths to calculate the exchange rate between any two currencies using the central currency.

there is one of this for vx / vx ace version, but you have also YEP_MoreCurrency, which allow this kind of this.

the bad thing (in my opinion) is that it need the shop core to work, but there isn't a seperate one.
if you know the MoreCurrency plugin of yanfly, you can make it so, you can input any kind of currency (multiple)
so you can do gold, silver, copper, ruby, diamonds etc etc.

but Idk how to handly this kind. I know you can event the big bunch, but plugin would be much nicer though.
That plugin doesn't have exchange rates like @nio kasgami was thinking about where 1 gold is 100 silver. The More Currencies plugin you have to manually set the price for every item for every currency -- this is an interesting idea and it's not the same plugin, you should try to make it!
 
Last edited:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
@Aloe Guvner I actually figured out how to do the currency exchange rate by using Exponantial and off course using ratio if people want to set manually.

THe way to calculate every ratio even example silver to gold is by transferring the silver to Cooper then transfers to the desired unit.

so pretty much like this :
Code:
    /**
     * Convert the currency to the lowest
     * @param {currencyStruct} currency
     */
    convertToLowestCurrency(currency) {
        if (currency.id != 1) continue;
        const ratio = Math.pow(10, currency.id);
        let conversion = Math.floor(currency.ammount * ratio);
        return conversion;
       
    }

    convertToHighestCurrency(currency) {
        const ratio = Math.pow(10, this._currencies.length + 1); // make sure that people understand the ID should be the same as the array but + 1?
        let conversion = this.convertToLowestCurrency(currency);
        const prices = Math.floor(conversion + ratio);
        return prices
    }

don't mind the messiness I was testing I will refactor the coding later

my problem is that risk of losing money sinces I convert to integer and not to float and it risk to lose money by transfering
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,584
Latest member
Faustus2501
Top