Currency System
-Tsukihime
Overview
This script replaces the default currency system with a more sophisticated way of managing currency.
It allows you to easily create as many currencies as you want in the game, and exchange between currencies through events.
Usage
Start by setting up the currencies in the game.
In the configuration at the top, you will see a Currencies table. You can have as many currencies as you want by entering the appropriate entries.
Each currency has an ID which you will be using throughout the project.
Each currency contains a display name, a symbol, as well as an exchange value.
Some simple script calls for getting or losing money:
Code:
- $game_party.gain_money(amount, currency_id)
- $game_party.lose_money(amount, currency_id)
复制代码
By default, the currency_id is the currency currently in use (more info below), so it can be omitted if you want it to be based on the current currency.
The exchange value determines how much the currency is worth.
For example, suppose we have the following setup
Code:
- { 1 => ["Gold", "G", 5],
- 2 => ["Silver", "S", 1]
- }
复制代码
This means that
For each gold you exchange, you receive 5 silvers
For each silver you exchange, you receive 0.2 golds
In order to exchange currency, use the script call
Code:
- $game_party.exchange_currency(src, dest, amount)
- $game_party.exchange_currency(1, 2, 200)
复制代码
You pass in two currency ID's, the currency you start with, and the currency you want to exchange to, as well as the amount. The script will use the exchange values defined in the Currency table to calculate the exchange rate and add/subtract the appropriate amounts from the two currencies.
Different currencies can be used throughout the game.
At this time, only one currency may be used at anytime.
You can change the global currency by calling
Code:
- change_currency(currency_id)
- change_currency(1) # change the gold
- change_currency(2) # change to silver
复制代码
This allows you to simulate different currencies in different cities or regions.
The currency that is displayed in your main menu is the currency that is currently used.
If you want to see all of your currencies, use the script call
Code:
- SceneManager.call(Scene_PartyBank)
复制代码
I have added it to the main menu for the default system.
Examples
SpoilerYou would use an event to set up currency exchange.
Suppose I start with 5000 silvers
I then ask the NPC to exchange silvers to gold
After I exchanged 100 silvers, this is what I have
With an exchange rate of 5 Silver = 1 Gold, that is expected.
Download
Script:
http://db.tt/U9bBddiZ
Notes
Having a specialized "Money" scene to view your party's funds should be created. Does anyone want to write it?
Also, a "currency exchange" scene would make it much easier to exchange currencies. Someone want to do that?
Basic money window I've added for the default system. You can access it via Scene_PartyBank.
It needs improvement but I'm not a designer.
本贴来自国际rpgmaker官方论坛作者:Tsukihime处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/currency-system.3023/