cooldoode325

Custom Equip Types

Feb 24th, 2014
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. =begin
  2. #===============================================================================
  3. Title: Custom Equip Types
  4. Author: Tsukihime
  5. Date: Jul 25, 2013
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. Jul 25, 2013
  9. - Initial release
  10. --------------------------------------------------------------------------------
  11. ** Terms of Use
  12. * Free to use in non-commercial projects
  13. * Contact me for commercial use
  14. * No real support. The script is provided as-is
  15. * Will do bug fixes, but no compatibility patches
  16. * Features may be requested but no guarantees, especially if it is non-trivial
  17. * Credits to Tsukihime in your project
  18. * Preserve this header
  19. --------------------------------------------------------------------------------
  20. ** Description
  21.  
  22. This script allows you to create custom equip types with their own equip
  23. slot names. You can then assign custom equip types to different items.
  24.  
  25. --------------------------------------------------------------------------------
  26. ** Installation
  27.  
  28. Place this script below Materials and above Main
  29.  
  30. --------------------------------------------------------------------------------
  31. ** Usage
  32.  
  33. In the configuration section, set up the Equip_Types table with the custom
  34. equip types. Each equip type is given a unique number and a name.
  35.  
  36. To assign a custom equip type to an item, note-tag it with
  37.  
  38. <equip type: x>
  39.  
  40. Where x is one of the equip type ID's that you have set up in the table.
  41.  
  42. #===============================================================================
  43. =end
  44. $imported = {} if $imported.nil?
  45. $imported["TH_CustomEquipTypes"] = true
  46. #===============================================================================
  47. # ** Configuration
  48. #===============================================================================
  49. module TH
  50. module Custom_Equip_Types
  51.  
  52. # Set up your equip types here.
  53. # Format: etypeID => name
  54. Equip_Types = {
  55.  
  56. 0 => "Main Hand",
  57.  
  58. 1 => "Off-Hand",
  59.  
  60. 5 => "Head",
  61.  
  62. 6 => "Torso",
  63.  
  64. 7 => "Arms",
  65.  
  66. 8 => "Waist",
  67.  
  68. 9 => "Legs",
  69.  
  70. 10 => "Feet",
  71.  
  72. 11 => "Tome",
  73.  
  74. 12 => "Ring",
  75.  
  76. 13 => "Gem",
  77.  
  78. 14 => "Orb",
  79.  
  80. 15 => "Badge",
  81. }
  82. #===============================================================================
  83. # ** Rest of script
  84. #===============================================================================
  85. Regex = /<equip[-_ ]type:\s*(\d+)/i
  86. end
  87. end
  88.  
  89. module RPG
  90. class EquipItem < BaseItem
  91.  
  92. alias :th_custom_equip_types_etype_id :etype_id
  93. def etype_id
  94. load_notetag_custom_equip_type unless @custom_etype_checked
  95. th_custom_equip_types_etype_id
  96. end
  97.  
  98. def load_notetag_custom_equip_type
  99. @custom_etype_checked = true
  100. res = self.note.match(TH::Custom_Equip_Types::Regex)
  101. @etype_id = res[1].to_i if res
  102. end
  103. end
  104. end
  105.  
  106. module Vocab
  107. def self.etype(etype_id)
  108. TH::Custom_Equip_Types::Equip_Types[etype_id]
  109. end
  110. end
Advertisement
Add Comment
Please, Sign In to add comment