TheoAllen

Theo - Specific Sell Price

Aug 11th, 2013
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.54 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Specific Sell Price
  3. # Version : 1.0
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. ($imported ||= {})[:Theo_SellPrice] = true
  8. # =============================================================================
  9. # CHANGE LOGS:
  10. # -----------------------------------------------------------------------------
  11. # 2013.08.11 - Finished script
  12. # =============================================================================
  13. =begin
  14.  
  15.   Perkenalan :
  16.   Script ini berfungsi untuk spesifikasi harga item
  17.  
  18.   Cara penggunaan :
  19.   Pasang dibawah material namun diatas main
  20.   Gunakan tag <sell price: n> pada note armor, weapon, dan item. Dimana n
  21.   adalah harga jual barang tersebut.
  22.  
  23.   Terms of Use :
  24.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  25.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  26.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  27.  
  28. =end
  29. # =============================================================================
  30. # Tidak ada konfigurasi
  31. # =============================================================================
  32. class << DataManager
  33.  
  34.   alias theo_sell_price_load_db load_database
  35.   def load_database
  36.     theo_sell_price_load_db
  37.     load_price_database
  38.   end
  39.  
  40.   def load_price_database
  41.     ($data_armors + $data_weapons + $data_items).compact.each do |item|
  42.       item.load_price
  43.     end
  44.   end
  45.  
  46. end
  47.  
  48. class RPG::Item < RPG::UsableItem
  49.   attr_accessor :sell_price
  50.  
  51.   def load_price
  52.     @sell_price = 0
  53.     self.note.split(/[\r\n]+/).each do |line|
  54.       case line
  55.       when /<(?:SELL_PRICE|sell price): [ ]*(\d+)>/i
  56.         @sell_price = $1.to_i
  57.       end
  58.     end
  59.   end
  60.  
  61.   def specify_sell_price?
  62.     @sell_price > 0
  63.   end
  64.  
  65. end
  66.  
  67. class RPG::EquipItem < RPG::BaseItem
  68.   attr_accessor :sell_price
  69.  
  70.   def load_price
  71.     @sell_price = 0
  72.     self.note.split(/[\r\n]+/).each do |line|
  73.       case line
  74.       when /<(?:SELL_PRICE|sell price): [ ]*(\d+)>/i
  75.         @sell_price = $1.to_i
  76.       end
  77.     end
  78.   end
  79.  
  80.   def specify_sell_price?
  81.     @sell_price > 0
  82.   end
  83.  
  84. end
  85.  
  86. class Scene_Shop < Scene_MenuBase
  87.   alias theo_ori_sell_price selling_price
  88.   def selling_price
  89.     return @item.sell_price if @item.specify_sell_price?
  90.     return theo_ori_sell_price
  91.   end
  92. end
Advertisement
Add Comment
Please, Sign In to add comment