Jump to content
Calestian

Multiple Currencies

Recommended Posts

Author: Calestian


Name: Multiple Currencies


Version: 1.1


 


Features:


User can set more than one different currencies.


There is a new Menu tab displaying all currencies.


Different shops can use different currencies.


 


Images:


MOHG0ID.png?1


sEnhM9C.png?1


lGTVkbj.png?1


 


Script: Link:Multiple Currencies


Edited by Calestian

Share this post


Link to post
Share on other sites

 

Author: Calestian

Name: Multiple Currenciesarrow-10x10.png

Version: 1.0

 

Features:

User can set more than one different currenciesarrow-10x10.png.

There is a new Menu tab displaying all currenciesarrow-10x10.png.

Different shops can use different currenciesarrow-10x10.png.

 

Images:

MOHG0ID.png?1

sEnhM9C.png?1

lGTVkbj.png?1

 

Script: Link:Multiple Currencies

 

.... Did you see my Theory and Development post? XD I was asking for this exact script!!

Share this post


Link to post
Share on other sites

The script itself can support up to 11 currencies, anything more than that and the Currency window in your Menu is going to overflow.

 

In the Editable Region, in the module, change the Currency hash to customize currencies.

Example: 1 => [362, 0],    Generally: currency_index = [icon_index, starting_amount],         Note: currency_index can be 0-10.

This means your currency #1 will have the icon 361 (You can see the icon IDs in the database F9) and the starting amount of this currency for a new player will be 0.

 

 

Where you set the events, before the Shop Processing, set a new event (Script, under Advanced): 

Example: currency(1)    Generally: currency(currency_index)

This means the Shop you set in that particular event will have the currency #2. To use a different currency, simply change the currency index in the brackets. Currency(2) would be Currency #2.

 

If you want to gain gold, set a script again in the event window with the command.

Example: add_currency(100, 2)    Generally: add_currency(amount, currency_index)

This means that when the event is triggers, you will gain 100 of currency #2.

 

 

There are instructions at the top of the script as well.

Edited by Calestian

Share this post


Link to post
Share on other sites

The script itself can support up to 11 currencies, anything more than that and the Currencyarrow-10x10.png window in your Menu is going to overflow.

 

In the Editable Region, in the module, change the Currencyarrow-10x10.png hash to customize currencies.

Example: 1 => [362, 0],    Generally: currency_index = [icon_index, starting_amount],         Note: currency_index can be 0-10.

This means your currency #1 will have the icon 361 (You can see the icon IDs in the database F9) and the starting amount of this currency for a new player will be 0.

 

 

Where you set the events, before the Shoparrow-10x10.png Processing, set a new event (Script, under Advanced): 

Example: currency(1)    Generally: currency(currency_index)

This means the Shop you set in that particular event will have the currency #2. To use a different currency, simply change the currency index in the brackets. Currency(2) would be Currency #2.

 

If you want to gain gold, set a script againarrow-10x10.png in the event window with the command.

Example: add_currency(2)    Generally: add_currency(amount, currency_index)

This means that when the event is triggers, you will gain 100 of currency #2.

 

 

There are instructions at the top of the script as well.

... Huh...

Share this post


Link to post
Share on other sites

If you meant how you increase your currencies, the command would be:

add_currency(amount, currency_index)

Example:

Lets say you want to add to currency #2 after a a battle. In the window where you set the events, your events would be something like:

 

-    Battle Processing...

-    add_currency(100, 2)

 

So after the battle you will gain 100 of currency #2

Edited by Calestian

Share this post


Link to post
Share on other sites

Hi Calestian,

 

Thanks for the script but I can't seem to get the increase your currencies command to work on a blank project.  I get an error:  Script Game_Interpreter line 1411.  ArgumentError occurred.  wrong number of arguments (2 for 1).

 

I'm using the command on a chest for testing.  

 

@>Script: add_currency(100, 2)

Share this post


Link to post
Share on other sites

If you are using 4 currencies, their indexes are (0, 1, 2, 3). 3 is the 4th currency. 

 

So if you're using gain_currency for the 4th index (5th currency) which doesnt exist, it will throw an error.

 

I will make a better revision of the script in a week or two.

Share this post


Link to post
Share on other sites

If you are using 4 currencies, their indexes are (0, 1, 2, 3). 3 is the 4th currency. 

 

So if you're using gain_currency for the 4th index (5th currency) which doesnt exist, it will throw an error.

 

I will make a better revision of the script in a week or two.

I remove the currency from 5 to 10, and when I go to the game, it gives an error.
That's what's exactly the problem.

Share this post


Link to post
Share on other sites

 

It's impossible for me to tell you whats wrong without having the script. 

 

I need you to post the script after u modified it, and then i can give u a reply tomorrow.

 

Set the Icon to a blank one(on default Iconset, it's 140) and set the 2nd number to nil. It worked for me.

Share this post


Link to post
Share on other sites

Nice script Calestian but I'd like to know if you can replace the currency icon with a name or letter instead a of picture. 

 

Also what about converting one currency to another as well as exchange rates between different currencies as well as shops who use one type of currencies being able to accept other currencies at a fit exchange rate say the shop in question uses only platinum but will accept gold at a rate of 2 gold pieces to one platinum piece.

As well as money changers and banks that accept multi currencies at different interest rate for different currencies, say there is a 5% interest rate on the number platinum pieces in an account and an interest rate of 3% on the gold pieces in the account and so on. 

Edited by Kargan3033

Share this post


Link to post
Share on other sites
9 hours ago, Kargan3033 said:

Nice script Calestian but I'd like to know if you can replace the currency icon with a name or letter instead a of picture. 

 

You can simply make the name or letter an icon. As far as making it display text, it would require editing the script. Since the OP has long since vanished, someone else would likely have to do it. I'm no expert at this, so I would defer to another who would be better suited.

 

9 hours ago, Kargan3033 said:

Also what about converting one currency to another as well as exchange rates between different currencies as well as shops who use one type of currencies being able to accept other currencies at a fit exchange rate say the shop in question uses only platinum but will accept gold at a rate of 2 gold pieces to one platinum piece.

As well as money changers and banks that accept multi currencies at different interest rate for different currencies, say there is a 5% interest rate on the number platinum pieces in an account and an interest rate of 3% on the gold pieces in the account and so on. 

 

You can do this with variables and do the math yourself, really. Complicated? Sure. But really, that's half the fun in gamedev, unless you're the likes of Blizzard/Activision, or an asset flipper.

 

Also, I'll note that with this script, in order to change the number of currencies from eleven to something like four or five, you have to change certain working parts.

 

Under Class Game_Party in this script, there's a bit of code that has the following:
 

Spoiler

  def initialize
    @currency = []
    @gold = Clstn_Currencies::Currencies[0][1]
    11.times { |i|
      if i == 0
        @currency[i] = @gold
      else
        @currency[i] = Clstn_Currencies::Currencies[i][1]
      end
    }
    @steps = 0
    @last_item = Game_BaseItem.new
    @menu_actor_id = 0
    @target_actor_id = 0
    @actors = []
    init_all_items
  end

 

Notice the following line:

11.times { |i|

You'll want to change the number in 11.times to the number of currencies you wish to use, as well as removing/commenting out the unused currencies (commenting out is better from experience).So, for just needing five currencies, one would change that line to 5.times, and comment out currencies 5 - 10, because the currencies are 0-based; 0,1,2,3,4 should be what is left, and then boom, only those five currencies will be displayed.

 

I'll also take this time to insert an add-on for this script, which does require a script I wrote myself.

Spoiler

=begin
Add-On: Calestian Currencies - Set Gold and Set Currency

Original Script written by Calestian

Add-On/Mod written by Amyrakunejo for KB Games

Instructions:
Place below Calestian's Currencies script, directly below is best.

Only usable with KB-Set Gold Modifier script, this script must also be
placed below KB-Set Gold Modifier script.

Otherwise, Plug and Play, with the following sub-set of instructions:

With Calestian's Currency script, in the event's Advanced Script Call tab,
you can use the following two calls to do the following:
add_currency(amount, Currency_ID) to apply a currency gain
add_currency(-amount, Currency_ID) to apply a currency loss

With this Add-On script, and KB-Set Gold Modifier, the following
script call has also been added:
set_currency(amount, Currency_ID) to apply a currency set

Alternatively, one can use the following script call to set the currency:
$game_party.set_gold(amount, Currency_ID)

=end

class Game_Party < Game_Unit
  attr_accessor :currency
  
  #-------------------------------------------------------------------------
  # * Method: set_gold
  #-------------------------------------------------------------------------
  def set_gold(amount, currency_index = $game_temp.currency_index)
     if currency_index != 0
      @currency[currency_index] = [[@currency[currency_index] = amount, 0].max, max_gold].min #not invalid by the way
     else
      @gold = [[@gold = amount, 0].max, max_gold].min
  end
end

class Game_Interpreter
  
  #--------------------------------------------------------------------------
  # * Method: set_currency 
  #--------------------------------------------------------------------------
  def set_currency(amount, currency_index)
    $game_party.set_gold(amount, currency_index)
  end
 end
end



 

 

Then, my own script which goes above both Calestian's script and the add-on I made.

Spoiler

=begin
Set Gold
by KB, Amyrakunejo
Assisted by r/transprogrammer Discord, Kayzee

Instructions:
In the events script call, use the following:
$game_party.set_gold(#)
$game_party.set_gold($game_variables[#])

You'll have your gold set to the amount. By setting the gold directly,
there is no need to use gain or loss commands. Useful if you have an event
that will decrease or increase the gold to a specific amount, or if you have
an event condition that checks for a specific max or minimum gold, or,
you know, whatever you may find this useful for.

Usage:
Place above all other modifier scripts for best performance.

Script conflicts:
Calestian's Currencies will need some serious editing to get this
script to work with it. If you succeed at this, let me know, thanks.
Addendum: I made a compatibility patch that works flawlessly.

Other known conflicts:
None yet.

Author requirements:
Commercial, Non-Commercial, I don't care. If you like this little script enough,
then all I'd like in return is for you to let me know. If you gave me a
free copy of your game, I'd appreciate that as well, but not necessary.
Is your game 18+ only? Cool by me, by the way. I'm not skeezy like most
script writers in this regard, like seriously; I'm kinky too. Jeez.
=end

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # * Set Gold
  #--------------------------------------------------------------------------
  def set_gold(amount)
#     @gold = amount
    @gold = [[@gold = amount, 0].max, max_gold].min
  end
end

 

 

And with that, I hope that settles the one issue someone else had a while back.

Edited by PhoenixSoul

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×