SHARE
TWEET

EST - SELECT CURRENCY

estriole Oct 27th, 2013 237 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2.  ■ Information      ╒═════════════════════════════════════════════════════════╛
  3.  EST - SELECT_CURRENCY v1.3
  4.  by Estriole
  5.  
  6.  ■ License          ╒═════════════════════════════════════════════════════════╛
  7.  Free to use in all project (except the one containing pornography)
  8.  as long as i credited (ESTRIOLE).
  9.  
  10.  ■ Support          ╒═════════════════════════════════════════════════════════╛
  11.  While I'm flattered and I'm glad that people have been sharing and asking
  12.  support for scripts in other RPG Maker communities, I would like to ask that
  13.  you please avoid posting my scripts outside of where I frequent because it
  14.  would make finding support and fixing bugs difficult for both of you and me.
  15.    
  16.  If you're ever looking for support, I can be reached at the following:
  17.  ╔═════════════════════════════════════════════╗
  18.  ║       http://www.rpgmakervxace.net/         ║
  19.  ╚═════════════════════════════════════════════╝
  20.  pm me : Estriole.
  21.  
  22.  ■ Requirement     ╒═════════════════════════════════════════════════════════╛
  23.  Mandatory : EST - CONSTANT CHANGER
  24.  http://pastebin.com/H0UjHukK
  25.  
  26.  ■ Introduction     ╒═════════════════════════════════════════════════════════╛
  27.  This script make you able to choose active currency. you can set anything
  28.  like variables and any other variable that have writer method (can be + or - or =)
  29.  useful for scenario where you have multiple countries. and when entering country A.
  30.  any money gained there will add to variable 1 (we can call it Dollar). any money
  31.  spent will substract from variable 1...
  32.  
  33.  another usage maybe for guild system. where we can purchase item using guild points
  34.  or city system where we purchase using city treasury.
  35.  
  36.  this script also make us can change the vocab for the buy, sell, cancel command.
  37.  so we can custom the shop a little. for better customization of the shop including
  38.  command, behavior when buying, etc. you might need another custom shop script.
  39.  
  40.  ■ Features         ╒═════════════════════════════════════════════════════════╛
  41.  - select your active currency
  42.  - purchase item using active currency
  43.  - active currency can be anything that have writer method
  44.  - gold gain will add to active currency IF active currency set
  45.  - gold lost will substract from active currency IF active currency set
  46.  - minor compatibility for yanfly jp manager (only able to select one actor and one class)
  47.    you can try mixing it with eventing if you want something complex.
  48.  - able to mod shop command vocab for different shop 'feel'
  49.  - compatibility with most shop script (for vocab change feature)
  50.  
  51.  ■ Changelog        ╒═════════════════════════════════════════════════════════╛
  52.  v1.0 2013.10.27           Initial Release
  53.  v1.1 2013.11.19           Updated the script with cleaner vocabulary changing.
  54.                            now more compatible with custom shop script. :D
  55.  v1.2 2013.11.19           some typo causing error and reseting currency not working
  56.  v1.3 2013.11.20           change the vocab changing method again since previous
  57.                            one don't work on saved files.
  58.                            NOW this script REQUIRE EST - CONSTANT CHANGER script
  59.                            http://pastebin.com/H0UjHukK
  60.                      
  61.  ■ Compatibility    ╒═════════════════════════════════════════════════════════╛
  62.  should be compatible with most script now...
  63.  
  64.  ■ How to use     ╒═════════════════════════════════════════════════════════╛
  65.  0) some basic knowledge... ALL thing that store NUMBER and have WRITER method
  66.  can be used as active currency. if you're curious what is WRITER method.
  67.  means you can write code: yourvariablename += 10 and not throw error.
  68.  
  69.  all Array element already have writer method. so $game_variables[10] can be used
  70.  as active currency. because we can script call $game_variables[10] += 10 and not
  71.  throw error.
  72.  
  73.  so basically ALL $game_variables member can be used as your active currency.
  74.  
  75.  yanfly JP Manager script store jp in $game_actors[actor_id] array @jp[class_id]
  76.  so i add compatibility patch so you can use:
  77.  $game_actors[1].jp[1] to use actor 1 class 1 jp
  78.  
  79.  1) to set active currency. script call:
  80.  
  81.  active_currency("your currency ruby code in string")
  82.  
  83.  ex:
  84.  active_currency("$game_variables[1]")
  85.  will use variable 1 as active currency.
  86.  
  87.  active_currency("$game_actors[1].jp[1]")
  88.  will use actor 1 class 1 jp as active currency
  89.  
  90.  after you set active currency. any ADDITION / REDUCTION to gold will add to
  91.  active currency instead. this including:
  92.  > buy or sell goods at shop
  93.  > get money from battle
  94.  > get money from event
  95.  
  96.  2) to back using plain old gold. just script call anytime:
  97.  
  98.  reset_currency
  99.  
  100.  it will also reset the vocab changes
  101.  
  102.  
  103.  3) to change the shop vocab for different 'feel'. script call:
  104.  
  105.  currency_unit("String")
  106.  buy_vocab("String")
  107.  sell_vocab("String")
  108.  cancel_vocab("String")
  109.  possession_vocab("String")
  110.  
  111.  ex:
  112.  currency_unit("Soul")
  113.  buy_vocab("Create")
  114.  sell_vocab("Convert")
  115.  cancel_vocab("End Sermon")
  116.  possession_vocab("Owned")
  117.  will change currency unit to Soul, buy vocab to Create, sell vocab to Convert,
  118.  cancel vocab to End Sermon, and possession vocab to Owned
  119.  
  120.  4) ** profit **
  121.  
  122.  ■ Author's Notes   ╒═════════════════════════════════════════════════════════╛
  123.  
  124. =end
  125.  
  126. module ESTRIOLE
  127.   module SELECT_CURRENCY
  128.   ESTRIOLE_SCRIPTS_ARE_AWESOME = true
  129.   # LOL just kidding.
  130.   end
  131. end
  132.  
  133. #game interpreter method for shorter call
  134. class Game_Interpreter
  135.   def active_currency(cur)
  136.     $game_party.active_currency = cur
  137.   end
  138.   def currency_unit(unit)
  139.     $game_party.currency_unit = unit
  140.   end
  141.   def buy_vocab(str)
  142.     est_change_vocab("ShopBuy", str)
  143.   end
  144.   def sell_vocab(str)
  145.     est_change_vocab("ShopSell", str)
  146.   end
  147.   def cancel_vocab(str)
  148.     est_change_vocab("ShopCancel", str)
  149.   end
  150.   def possession_vocab(str)
  151.     est_change_vocab("Possession", str)
  152.   end
  153.   def reset_buy_vocab
  154.     est_reset_vocab("ShopBuy")
  155.   end
  156.   def reset_sell_vocab
  157.     est_reset_vocab("ShopSell")
  158.   end
  159.   def reset_cancel_vocab
  160.     est_reset_vocab("ShopCancel")
  161.   end
  162.   def reset_possession_vocab
  163.     est_reset_vocab("Possession")
  164.   end
  165.   def reset_currency
  166.     $game_party.active_currency = nil
  167.     $game_party.currency_unit = nil
  168.     reset_buy_vocab
  169.     reset_sell_vocab
  170.     reset_cancel_vocab
  171.     reset_possession_vocab
  172.   end
  173. end
  174.  
  175. class Game_Party < Game_Unit
  176.   #attr_reader active currency variable
  177.   def active_currency
  178.     @active_currency
  179.   end
  180.   #attr_write active currency variable
  181.   def active_currency=(cur)
  182.     return if @active_currency == cur
  183.     @active_currency = cur
  184.   end
  185.   #alias method gold so it can use active currency if exist
  186.   alias est_select_currency_gold gold
  187.   def gold
  188.     return eval(active_currency) if active_currency
  189.     est_select_currency_gold
  190.   end
  191.   #alias method attr_writer gold to use active currency instead
  192.   def gold=(gold)
  193.     return eval("#{active_currency} = #{gold}") if active_currency
  194.     @gold = gold
  195.   end
  196.   #alias method gold gain to add to active currency instead
  197.   alias est_select_currency_gain_gold gain_gold
  198.   def gain_gold(amount)
  199.     return eval("#{active_currency} = [[#{active_currency} + amount, 0].max, max_gold].min")if active_currency
  200.     est_select_currency_gain_gold(amount)
  201.   end
  202.  
  203.   #attr_reader and writer for the currency unit vocab
  204.   def currency_unit
  205.     @currency_unit
  206.   end
  207.   def currency_unit=(unit)
  208.     return if @currency_unit == unit
  209.     @currency_unit = unit
  210.   end
  211. end
  212.  
  213. module Vocab
  214.   class << self
  215.     alias est_select_currency_currency_unit currency_unit
  216.   end
  217.   #alias method currency unit to return active currency unit instead
  218.   def self.currency_unit
  219.     return $game_party.currency_unit if $game_party.currency_unit
  220.     est_select_currency_currency_unit
  221.   end
  222. end
  223.  
  224. #yanfly jp system compatibility
  225. class Game_Actor < Game_Battler
  226.   alias est_select_currency_jp jp
  227.   def jp(class_id = nil)
  228.     return @jp if !class_id
  229.     est_select_currency_jp(class_id)
  230.   end
  231. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top