TheSixth

Auto-Close Actor Window on 0 Item Snippet by Sixth

Sep 4th, 2015 (edited)
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.45 KB | None | 0 0
  1. #===============================================================================
  2. # A small snippet which makes the actor selection window automatically close
  3. # itself after using an item if it was the last item of that kind in the
  4. # inventory.
  5. # Made by: Sixth
  6. #===============================================================================
  7. class Scene_Item < Scene_ItemBase
  8.  
  9.   alias sixth_zeroitem1222 start
  10.   def start
  11.     sixth_zeroitem1222
  12.     @zero = false
  13.   end
  14.  
  15.   alias sixth_zeroitem7765 on_item_ok
  16.   def on_item_ok
  17.     if @item_window.current_item_enabled? && @zero == false
  18.       Sound.play_ok
  19.       sixth_zeroitem7765
  20.     elsif !@item_window.current_item_enabled? && @zero == false
  21.       Sound.play_buzzer
  22.       @item_window.activate
  23.     else
  24.       @item_window.activate
  25.       @zero = false
  26.     end      
  27.   end
  28.  
  29.   alias sixth_zeroitem3354 use_item
  30.   def use_item
  31.     sixth_zeroitem3354
  32.     if item.is_a?(RPG::Item) && $game_party.item_number(item) == 0
  33.       @zero = true
  34.       @item_window.select(0)
  35.       hide_sub_window(@actor_window)
  36.     end
  37.   end
  38.  
  39. end
  40.  
  41. class Window_ItemList < Window_Selectable
  42.    
  43.   def process_ok
  44.     return super if $game_party.in_battle
  45.     Input.update
  46.     deactivate
  47.     call_ok_handler
  48.   end
  49.  
  50. end
  51. #==============================================================================
  52. # !!END OF SCRIPT - OHH, NOES!!
  53. #==============================================================================
Add Comment
Please, Sign In to add comment