TheoAllen

Theo - Dual Terms

Jun 7th, 2013
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.06 KB | None | 0 0
  1. # =============================================================================
  2. # TheoAllen - Dual Terms
  3. # Version : 1.0b
  4. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  7. # Requested by : emjenoeg
  8. # =============================================================================
  9. ($imported ||= {})[:Theo_DualTerms] = true
  10. # =============================================================================
  11. # CHANGE LOGS:
  12. # -----------------------------------------------------------------------------
  13. # 2013.06.08 - Bugfix at description notetag
  14. # 2013.06.08 - Finished script
  15. # =============================================================================
  16. =begin
  17.  
  18.   Perkenalan :
  19.   Script ini ngebikin kamu punya alternative name dan description untuk item2
  20.   yang ada di dalam game. Dan juga alternative command. Terms2 alternative itu
  21.   akan menggantikan yang asli jika switch tertentu
  22.  
  23.   Cara penggunaan :
  24.   Pasang dibawah material namun diatas main
  25.   Edit konfigurasinya
  26.  
  27.   Semisal kamu prefer make notetag, maka gunain tag berikut di database
  28.   <name: potion>
  29.  
  30.   <desc>
  31.   line pertama
  32.   line kedua
  33.   </desc>
  34.  
  35.   Terms of use :
  36.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  37.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  38.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  39.  
  40. =end
  41. # =============================================================================
  42. # Konfigurasi
  43. # =============================================================================
  44. module THEO
  45.   module BASEITEM
  46.     # Switch ID untuk digunakan switch (jika ON, maka akan diganti)
  47.     DUAL_SWITCH = 1
  48.    
  49.     # Kalo u gunain alternative command juga ~
  50.     USE_ALT_COMMAND = true
  51.     # -------------------------------------------------------------------------
  52.     # Commands
  53.     # -------------------------------------------------------------------------
  54.     ALT_COMMANDS = {
  55.       0   => "Lawan",           # Fight
  56.       1   => "Kabur",           # Escape
  57.       2   => "Serang",          # Attack
  58.       3   => "Bertahan",        # Defend
  59.       4   => "Barang",          # Items
  60.       5   => "Kemampuan",       # Skills
  61.       6   => "Perlengkapan",    # Equipments
  62.       7   => "Status",          # Status
  63.       8   => "Formasi",         # Formation
  64.       9   => "Simpan",          # Save
  65.       10  => "Keluar",          # End
  66.      
  67.       # nomor 11 ga dipake ~
  68.      
  69.       12  => "Senjata",         # Weapons
  70.       13  => "Baju Pelindung",  # Armors
  71.       14  => "Kunci-kunci",     # Key-Item
  72.       15  => "Ganti",           # Change
  73.       16  => "Optimasi",        # Optimize
  74.       17  => "Lepas semua",     # Remove all
  75.       18  => "Mulai baru",      # New Game
  76.       19  => "Lanjut",          # Continue
  77.       20  => "Keluar",          # Shutdown
  78.       21  => "Ke title",        # To title
  79.       22  => "Ga jadi",         # Cancel
  80.     }
  81.    
  82.     # -------------------------------------------------------------------------
  83.     # WARNING! Jika tidak dipake, kosongin aja. Ngehapus salah satu akan
  84.     # mengakibatkan error
  85.     # -------------------------------------------------------------------------
  86.     # -------------------------------------------------------------------------
  87.     # Items
  88.     # -------------------------------------------------------------------------
  89.     ALT_ITEM_NAME = {
  90.       1 => "Jamu",
  91.       2 => "Jamu Kuat",
  92.       3 => "STMJ",
  93.       4 => "Aqua galon",
  94.       # Lanjutin ndiri ~
  95.     }
  96.    
  97.     ALT_ITEM_DESC = {
  98.       1 => "Jamu iki marai kuat lan perkoso",
  99.       2 => "Jamu iki marai kuat koyo ariel",
  100.       3 => "Pokok e manteb tenan",
  101.       # Lanjutin ndiri ~
  102.     }
  103.    
  104.     # -------------------------------------------------------------------------
  105.     # Skills
  106.     # -------------------------------------------------------------------------
  107.     ALT_SKILL_NAME = {
  108.       # Isi sendiri ~
  109.     }
  110.    
  111.     ALT_SKILL_DESC = {
  112.       # Isi sendiri ~
  113.     }
  114.    
  115.     # -------------------------------------------------------------------------
  116.     # Weapons
  117.     # -------------------------------------------------------------------------
  118.     ALT_WEAPON_NAME = {
  119.       # Isi sendiri ~
  120.     }
  121.    
  122.     ALT_WEAPON_DESC = {
  123.       # Isi sendiri ~
  124.     }
  125.    
  126.     # -------------------------------------------------------------------------
  127.     # Armors
  128.     # -------------------------------------------------------------------------
  129.     ALT_ARMOR_NAME = {
  130.       # Isi sendiri ~
  131.     }
  132.    
  133.     ALT_ARMOR_DESC = {
  134.       # Isi sendiri ~
  135.     }
  136.    
  137.     # -------------------------------------------------------------------------
  138.     # States
  139.     # -------------------------------------------------------------------------
  140.     ALT_STATE_NAME = {
  141.       # Isi sendiri ~
  142.     }
  143.    
  144.     # -------------------------------------------------------------------------
  145.     # Enemy
  146.     # -------------------------------------------------------------------------
  147.     ALT_ENEMY_NAME = {
  148.       # Isi sendiri ~
  149.     }
  150.    
  151.   end
  152. end
  153. # =============================================================================
  154. # Akhir dari konfigurasi
  155. # =============================================================================
  156. module THEO
  157.   module BASEITEM
  158.   module REGEXP
  159.    
  160.     ALT_NAME      = /<(?:NAME|name):(.*)>/i
  161.     ALT_DESC_ON   = /<(?:DESC|desc)>/i
  162.     ALT_DESC_OFF  = /<\/(?:DESC|desc)>/i
  163.    
  164.   end
  165.   end
  166. end
  167.  
  168.  
  169. class RPG::BaseItem
  170.  
  171.   include THEO::BASEITEM
  172.  
  173.   alias ori_name name
  174.   def name
  175.     return ori_name unless $game_switches
  176.     $game_switches[DUAL_SWITCH] ? @alt_name : ori_name
  177.   end
  178.  
  179.   alias ori_desc description
  180.   def description
  181.     return ori_desc unless $game_switches
  182.     $game_switches[DUAL_SWITCH] ? @alt_desc : ori_desc
  183.   end
  184.  
  185.   def target_desc
  186.     return {}
  187.   end
  188.  
  189.   def target_name
  190.     return {}
  191.   end
  192.  
  193.   def load_alternatives
  194.     @read_desc = false
  195.     @alt_name = target_name.include?(self.id) ? target_name[self.id] : @name
  196.     @alt_desc = target_desc.include?(self.id) ? target_desc[self.id] : @description
  197.     self.note.split(/[\r\n]+/).each do |line|
  198.       case line
  199.       when REGEXP::ALT_NAME
  200.         @alt_name = $1.to_s
  201.       when REGEXP::ALT_DESC_ON
  202.         @read_desc = true
  203.         @alt_desc = ""
  204.       when REGEXP::ALT_DESC_OFF
  205.         @read_desc = false
  206.       else
  207.         next unless @read_desc
  208.         @alt_desc += line.to_s + "\n"
  209.       end
  210.     end
  211.   end
  212.  
  213. end
  214.  
  215. class RPG::Item < RPG::UsableItem
  216.   def target_name
  217.     ALT_ITEM_NAME
  218.   end
  219.  
  220.   def target_desc
  221.     ALT_ITEM_DESC
  222.   end
  223. end
  224.  
  225. class RPG::Skill < RPG::UsableItem
  226.   def target_name
  227.     ALT_SKILL_NAME
  228.   end
  229.  
  230.   def target_desc
  231.     ALT_SKILL_DESC
  232.   end
  233. end
  234.  
  235. class RPG::Weapon < RPG::EquipItem
  236.   def target_name
  237.     ALT_WEAPON_NAME
  238.   end
  239.  
  240.   def target_desc
  241.     ALT_WEAPON_DESC
  242.   end
  243. end
  244.  
  245. class RPG::Armor < RPG::EquipItem
  246.   def target_name
  247.     ALT_ARMOR_NAME
  248.   end
  249.  
  250.   def target_desc
  251.     ALT_ARMOR_DESC
  252.   end
  253. end
  254.  
  255. class RPG::States < RPG::BaseItem
  256.   def target_name
  257.     ALT_STATE_NAME
  258.   end
  259. end
  260.  
  261. class RPG::Enemy < RPG::BaseItem
  262.   def target_name
  263.     ALT_ENEMY_NAME
  264.   end
  265. end
  266.  
  267. class RPG::System::Terms
  268.  
  269.   include THEO::BASEITEM
  270.  
  271.   def load_alternatives
  272.     @alt_commands = []
  273.     ALT_COMMANDS.each do |id,term|
  274.       @alt_commands[id] = term
  275.     end
  276.   end
  277.  
  278.   alias ori_commands commands
  279.   def commands
  280.     return ori_commands unless $game_switches || USE_ALT_COMMAND
  281.     $game_switches[DUAL_SWITCH] ? @alt_commands : @commands
  282.   end
  283.  
  284. end
  285.  
  286. class << DataManager
  287.  
  288.   alias pre_alter_load_db load_database
  289.   def load_database
  290.     pre_alter_load_db
  291.     load_alternatives
  292.   end
  293.  
  294.   def load_alternatives
  295.     ($data_items + $data_skills + $data_weapons + $data_armors + $data_enemies +
  296.        $data_states + [$data_system.terms]).compact.each do |database|
  297.         database.load_alternatives
  298.       end
  299.   end
  300.  
  301. end
Advertisement
Add Comment
Please, Sign In to add comment