molegato

molegato_functions_V1.1

Feb 10th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. #==============================================================================
  2. # MOLEGATO FUNCTIONS
  3. # Author Molegato
  4. # Version 1.1
  5. #------------------------------------------------------------------------------
  6. # Several methods that I use in my scripts.
  7. #------------------------------------------------------------------------------
  8. # Included in some of my scripts. May be needed for those that dont include it
  9. # in order to make them work.
  10. #==============================================================================
  11.  
  12. #==============================================================================
  13. # MOLEGATO GAME_EVENT
  14. #------------------------------------------------------------------------------
  15. # Several methods for Game_Event
  16. #==============================================================================
  17. class Game_Event < Game_Character
  18.  
  19. def note
  20. string_note=""
  21.  
  22. return "" if not list
  23.  
  24. for i in 0..list.size-1
  25. if list[i] and list[i].code==108
  26. string_note += list[i].parameters[0]
  27. end
  28. end
  29. return string_note
  30. end
  31.  
  32. end
  33.  
  34.  
  35. #==============================================================================
  36. # MOLEGATO BattleManager
  37. #------------------------------------------------------------------------------
  38. # Several methods for BattleManager
  39. #==============================================================================
  40. module BattleManager
  41.  
  42. def self.action_battlers
  43. return @action_battlers
  44. end
  45.  
  46. def self.delete_battler_from_turn(battler)
  47. @action_battlers.delete(battler)
  48. end
  49. end
  50.  
  51. #==============================================================================
  52. # MOLEGATO WINDOW BASE
  53. #------------------------------------------------------------------------------
  54. # Several methods for window_base
  55. #==============================================================================
  56.  
  57. class Window_Base < Window
  58. def draw_face_scaled(face_name, face_index, x, y, scale,enabled = true)
  59. bitmap = Cache.face(face_name)
  60. rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
  61. rect2 = Rect.new(x,y, 96*scale, 96*scale)
  62. contents.stretch_blt(rect2, bitmap, rect,enabled ? 255 : translucent_alpha)
  63. bitmap.dispose
  64. end
  65.  
  66. def draw_actor_face_scaled(actor, x, y, scale, enabled = true)
  67. draw_face_scaled(actor.face_name, actor.face_index, x, y, scale, enabled)
  68. end
  69.  
  70. def draw_system(name, x, y)
  71. bitmap = Cache.system(name)
  72. rect = Rect.new(0, 0, bitmap.width, bitmap.width)
  73. contents.blt(x, y, bitmap, rect, 255)
  74. end
  75.  
  76. def instant_close
  77. @openness=0
  78. @closing=false
  79. @opening=false
  80. end
  81.  
  82. def instant_open
  83. @openness=255
  84. @closing=false
  85. @opening=false
  86. end
  87.  
  88. end
  89.  
  90. #==============================================================================
  91. # MOLEGATO TAG METHODS
  92. #------------------------------------------------------------------------------
  93. # Several methods for using tags. Needed by some of my scripts.
  94. #==============================================================================
  95.  
  96. module MOLEGATO_TAG_METHODS
  97. def has_tag?(tag)
  98. if self.note[/<#{tag}>/mi]
  99. return true
  100. else
  101. return false
  102. end
  103. end
  104.  
  105. def tag_check_value(tag)
  106. if self.note[/<#{tag}: (.*?)>/mi]
  107. return $1
  108. else
  109. return false
  110. end
  111. end
  112.  
  113. def tag_check_multivalues(tag)
  114. if self.note[/<#{tag}: (.*?)>/mi]
  115. return $1.split(',')
  116. else
  117. return false
  118. end
  119. end
  120.  
  121. def tag_check_multivalues(string, tag)
  122. if string[/<#{tag}: (.*?)>/mi]
  123. return $1.split(',')
  124. else
  125. return false
  126. end
  127. end
  128.  
  129. def tag_get_block(tag)
  130. if self.note[/<#{tag}>(.*?)<\\#{tag}>/mi]
  131. return $1
  132. else
  133. return false
  134. end
  135. end
  136.  
  137. def tag_multiple(tag)
  138. if tag_get_block(tag)
  139. var=tag_get_block(tag)
  140. return var.split(';')
  141. else
  142. return false
  143. end
  144. end
  145.  
  146. def tag_check_multiple_multivalues(tag)
  147. if tag_multiple(tag)
  148. array=[]
  149. tag_multiple(tag).each do |each|
  150. array.push(tag_check_multivalues(each,tag))
  151. end
  152. return array
  153. else
  154. return false
  155. end
  156. end
  157.  
  158. end
  159.  
  160. #---For items/skills/actors/etc
  161. class RPG::BaseItem
  162. include MOLEGATO_TAG_METHODS
  163. end
  164.  
  165. #---for maps
  166. class RPG::Map
  167. include MOLEGATO_TAG_METHODS
  168. end
  169.  
  170. #---for events
  171. class Game_Event < Game_Character
  172. include MOLEGATO_TAG_METHODS
  173. end
Advertisement
Add Comment
Please, Sign In to add comment