Advertisement
SSTrihan

HorrorVale - Item Unsort

Nov 27th, 2023
1,448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.36 KB | Source Code | 0 0
  1. #-------------------------------------------------------------------------------
  2. # Don't remove this header!
  3. #-------------------------------------------------------------------------------
  4. # Item Unsort
  5. # by Trihan
  6. #
  7. # Version : 1.0
  8. #
  9. # This script is commissioned by Batworks Software.
  10. #-------------------------------------------------------------------------------
  11.  
  12. #-------------------------------------------------------------------------------
  13. # Version History
  14. #-------------------------------------------------------------------------------
  15. # 1.0 - Initial script.
  16. #-------------------------------------------------------------------------------
  17.  
  18. #-------------------------------------------------------------------------------
  19. # This script removes the sorting of items/equipment in favour of arranging them
  20. # in the order they were obtained.
  21. #-------------------------------------------------------------------------------
  22.  
  23. class Game_Party < Game_Unit
  24.   alias :tlb_itemsort_initialize :initialize
  25.   def initialize
  26.     tlb_itemsort_initialize
  27.     @item_timestamps = {}
  28.     @weapon_timestamps = {}
  29.     @armor_timestamps = {}
  30.   end
  31.  
  32.   alias :tlb_itemsort_gain_item :gain_item
  33.   def gain_item(item, amount, include_equip = false)
  34.     tlb_itemsort_gain_item(item, amount, include_equip)
  35.     container = item_container(item.class)
  36.     return unless container
  37.     t_container = timestamp_container(item.class)
  38.     return unless t_container
  39.     if !container[item.id]
  40.       t_container.delete(item.id)
  41.     else
  42.       return if t_container[item.id]
  43.       t_container[item.id] = Graphics.frame_count
  44.     end
  45.   end
  46.  
  47.   def timestamp_container(item_class)
  48.     return @item_timestamps   if item_class == RPG::Item
  49.     return @weapon_timestamps if item_class == RPG::Weapon
  50.     return @armor_timestamps  if item_class == RPG::Armor
  51.     return nil
  52.   end
  53.  
  54.   def items
  55.     @item_timestamps = {} if !@item_timestamps
  56.     @items.keys.sort.sort_by {|id| @item_timestamps[id] }.collect {|id| $data_items[id] }
  57.   end
  58.  
  59.   def weapons
  60.     @weapon_timestamps = {} if !@weapon_timestamps
  61.     @weapons.keys.sort.sort_by {|id| @weapon_timestamps[id] }.collect {|id| $data_weapons[id] }
  62.   end
  63.  
  64.   def armors
  65.     @armor_timestamps = {} if !@armor_timestamps
  66.     @armors.keys.sort.sort_by {|id| @armor_timestamps[id] }.collect {|id| $data_armors[id] }
  67.   end
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement