Jump to content
Sign in to follow this  
Tsukihime

Change Currency

Recommended Posts

Change Currency

-Tsukihime

 

This script allows you to change currency.

However, at the moment it only supports changing the currency symbol.

 

Download

 

Script: http://db.tt/6EJAKmMG

 

Usage

 

Start by filling out the Currency Table in the configuration.

To change the currency in use, in an event script call, use

 

$game_system.change_currency(:symbol)

Where the symbol is defined in the Currency Table below.

 

Extension

 

I have provided a Currency Table that will store meta-data about each currency. All it stores is the symbol to be used at the moment.

 

Ideally, the script should store the user's currencies somewhere and then whenever `change_currency` is called, you would swap out the party's currency with the other one.

 

I will leave that to someone that wants to figure out how to write it. It can be written in about 20 lines of code or less.

Edited by Tsukihime

Share this post


Link to post
Share on other sites
Spoiler

=begin
#==============================================================================
 ** Change Currency
 Author: Hime
 Date: Jan 3, 2013
------------------------------------------------------------------------------
 ** Change log
 Jan 3, 2013
   - Initial release
------------------------------------------------------------------------------   
 ** Terms of Use
 * Free to use in non-commercial projects
 * Contact me for commercial use
 * No real support. The script is provided as-is
 * Will do bug fixes, but no compatibility patches
 * Features may be requested but no guarantees, especially if it is non-trivial
 * Preserve this header
------------------------------------------------------------------------------
 ** Description
 
 This script allows you to change the current currency.
 It supports changing the currency symbol only.
 
------------------------------------------------------------------------------
 ** Usage
 
 Start by filling out the Currency Table in the configuration.
 To change the currency in use, in an event script call, use
   
   $game_system.change_currency(:symbol)
   
 Where the symbol is defined in the Currency Table below.
#==============================================================================
=end
$imported = {} if $imported.nil?
$imported["Tsuki_ChangeCurrency"] = true
#==============================================================================
# ** Configuration
#==============================================================================
module Tsuki
  module Change_Currency
    
    # Fill in the different currencies in this table.
    # I have provided some sample entries
    Currency_Table = {
      :gold     => { :symbol => "G",
                },
      :silver   => { :symbol => "S",
                }
    }
    
    # Which one to use at the beginning
    Default_Currency = :gold
    
    def self.initial_currency
      Currency_Table[Default_Currency]
    end
  end
end
#==============================================================================
# ** Rest of the script
#============================================================================== 

module Vocab
  def self.currency_unit
    $game_system.currency_unit
  end
end

class Game_System
  
  attr_reader :currency_unit
  
  alias :th_currency_unit_init :initialize
  def initialize
    th_currency_unit_init
    @currency_unit = Tsuki::Change_Currency.initial_currency[:symbol]
  end
  
  def change_currency(sym)
    @currency_unit = Tsuki::Change_Currency::Currency_Table[sym][:symbol]
  end
end

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted