VanCoolz

[RGSS 2] Battle Variable Window

May 18th, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.28 KB | None | 0 0
  1. #==============================================================================
  2. # [RGSS 2] Battle Variable Window
  3. # Version : 1.0
  4. # Author : LowlingLife
  5. #==============================================================================
  6. # Script ini akan memunculkan window yang men-display variable di Battle.
  7. #==============================================================================
  8. module VariableWindow
  9.   # ID dari switch yang akan mengaktivasikan script.
  10.   SWITCH_ID = 5
  11.  
  12.   # Lokasi window.
  13.   # 0 - Kiri Atas
  14.   # 1 - Kanan Atas
  15.   # 2 - Tengah Atas
  16.   WINDOW_LOCATION = 0
  17.  
  18.   # Variable dan Icon yang akan di-display di Window.
  19.   # [Variable ID, Icon Index]
  20.   VAR_WINDOW = [1, 5]
  21. end
  22. #==============================================================================
  23. # EDITING BEYOND THIS LINE CAN CAUSE DAMAGE TO YOUR GAME, THEREFORE EDIT
  24. # WITH YOUR OWN RISK.
  25. #==============================================================================
  26. class Window_BVariable < Window_Base
  27.   include VariableWindow
  28.   def initialize(x, y)
  29.     super(x, y, 160, 64)
  30.     refresh
  31.   end
  32.  
  33.   def refresh
  34.     self.contents.clear
  35.     self.contents.draw_text(32, 0, 160, 32, $game_variables[VAR_WINDOW[0]].to_s)
  36.       draw_icon(VAR_WINDOW[1], 0, 0, enabled = true)
  37.     end
  38.   end
  39.  
  40. class Scene_Battle < Scene_Base
  41.   include VariableWindow
  42.  
  43.   alias var_window_start start
  44.   def start
  45.     var_window_start
  46.     super
  47.     if $game_switches[SWITCH_ID]
  48.     if WINDOW_LOCATION == 0
  49.       @battle_var_window = Window_BVariable.new(0, 0)
  50.     elsif WINDOW_LOCATION == 1
  51.       @battle_var_window = Window_BVariable.new(384, 0)
  52.     elsif WINDOW_LOCATION == 2
  53.       x = (Graphics.width - 160) / 2
  54.       @battle_var_window = Window_BVariable.new(x, 0)
  55.     end
  56.   end
  57.   end
  58.  
  59.   alias var_window_terminate terminate
  60.   def terminate
  61.     var_window_terminate
  62.     @battle_var_window.dispose if $game_switches[SWITCH_ID]
  63.   end
  64.  
  65.   alias var_window_update update_basic unless $@
  66.   def update_basic(*args, &block)
  67.     var_window_update(*args, &block)
  68.     @battle_var_window.update if $game_switches[SWITCH_ID]
  69.   end
  70.   #----------------------------------------------------------------------------
  71.   # END OF SCRIPT
  72.   #----------------------------------------------------------------------------
  73. end
Advertisement
Add Comment
Please, Sign In to add comment