Help - Search - Members - Calendar
Full Version: multiple currency system
RPG RPG Revolution Forums > Game Engines > RPG Maker VX Discussion
zubin73
I'm trying to implement a currency system in the game where if the player visits a particular city,he has to switch over to the currency of that city.for example-

the player visits the city 'X'.there the currency is bronze.so the player approaches the currency exchange and submits 'Y' amount to gold to get 'Z' amount of bronze.with that bronze now he can shop in the town or sleep at the inn.he can also change back bronze to gold before leaving the city.he can also retain some amount of bronze with him which will not function outside that city as currency.

So far I've been trying to implement that system by making bronze an item.but that is not acting as desired.may be logic was wrong while implementation.please guide me as to how can I change the 'gold' from the system to bronze and vice versa.
BasharTeg6
When a player goes to exchange one currency for another, save his current gold in a variable (set "Variable_Gold = player gold.) Then you can use a small bit of script to change the label for gold. Give me a minute and I'll look up how this is done for you...

EDIT: Here it is - $data_system.terms.gold = "Gold"

Where "Gold" is whatever you want the currency to be called. For example, if you want the currency to be called dollars, it would be $data_system.terms.gold = "dollars"

Just use the "Script" action to use this in an event.

Once you store the player's current gold in a variable, create a second variable called "exchange." Set exchange = Variable_Gold. Then, multiply "exchange" by whatever the exchange rate is for the new currency (let's say it's worth 50% more per unit than gold.) To do this, multiply "exchange" by 100 and then divide by 67. You have to do it in this round-about way because VX doesn't handle decimals well.

Now, decrease gold by "Variable_Gold" to set it to 0, then increase gold by "exchange." Viola, now you have the right amount of money. To switch back to gold you just have to decrease gold by "exchange," then increase gold by "Variable_Gold."

I hope that makes sense!

-Bash
zubin73
Thanks for taking time answering this,but I've trouble with
QUOTE
Then, multiply "exchange" by whatever the exchange rate is for the new currency (let's say it's worth 50% more per unit than gold.) To do this, multiply "exchange" by 100 and then divide by 67.


I can't declare the variables that holds the value for multiplication and division result in RMVX.

Edited:Ok I found the reason why I couldn't multiply or divide in RMVX.they had a bug in the game_interpreter.now I fixed it using their tools.I'll test your suggestion and get back.thanks!
zubin73
Ok I got a script for custom gold (or name it as any currency you want).It's very easy to use and quite simple.Here's the video link of the creator (though it's very difficult to make out anything).so I've added the scripts screenshots.

http://www.youtube.com/watch?v=C33T0b_IJek

insert script-



edits in other files of the script editor-









but now I'm stuck with a problem.but I can't figure out how to create a conditional branch to check whether there is any any custom gold remaining or not.I can't find the variable for the custom gold in the script that can be used to compare or check.

please help me.
BasharTeg6
The script call to set the custom gold to a variable should be something like this:

$game_variables[x] = CustomGold.gold

Where "x" is the number of the variable you want to use. I'm not familiar with this script though :\
zubin73
I set $game_variables[x] = CustomGold.gold using script and then used the conditional branch $game_variables[x] >= 20 to check whether the custom gold is more than 20 or not.I got a syntax error.where am I wrong?
BasharTeg6
QUOTE (zubin73 @ Feb 16 2010, 11:15 AM) *
I set $game_variables[x] = CustomGold.gold using script and then used the conditional branch $game_variables[x] >= 20 to check whether the custom gold is more than 20 or not.I got a syntax error.where am I wrong?


For "x" you need to put a number. Create a variable called "CustomGold." Whatever the number of that variable is on the list is the number you should use for "x." Then you don't need to use another script call, just use the conditional branch action.
zubin73
Did what you said.Now I get the following syntax error.

QUOTE
undefined method :gold in class CustomGold
BasharTeg6
As I said, I'm not totally familiar with this script so it may take some experimenting on your part. You need to direct the system to whatever the script is storing the gold amount in. Since CustomGold.gold didn't work it may be something else. Perhaps it's "$game_cg.gold". You'll have to play around with it a little until you find it.
zubin73
Yeah that is what I'm experimenting with.
But I appreciate your help.In the mean time I'm using your currency suggestion until I find a solution for this.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.