Advertisement
Zero_G

Skill Priority VX ACE

Nov 20th, 2022
969
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.80 KB | None | 0 0
  1. =begin
  2. ===============================================================================
  3.  Reorder Skills
  4.  Author: Zero_G
  5.  Version: RGSS3
  6. ===============================================================================
  7.   ==  Description ==
  8.  This script will let you reorder skills acording to priority. The higer the
  9.  priority the higher in the skill list a skill will appear.
  10.  
  11.  Use by setting <Sort Priority: X> on a skill note tag
  12.  ex: <Sort Priority: 2>
  13.  
  14.  A skill that has no priority set will behave the same as normal
  15.  
  16.  == Terms of Use ==
  17.  - Free for use in non-commercial projects with credits
  18.  - Free for use in commercial projects
  19.  - Please provide credits to Zero_G
  20.  
  21.  == Usage ==
  22.  Just add the plugin before main.
  23. -------------------------------------------------------------------------------
  24. =end
  25.  
  26. module ZERO_SKILL_PRIORITY
  27.   # Set a custom text before a skill name for a specific priority
  28.   MODIFY = true
  29.   PRIORITY = "2"
  30.   TEXT = "[W] "
  31.  
  32.   def self.getPriority(item)
  33.     regExp = /<Sort\s*Priority\s*:\s*(\d+)\s*>/i
  34.     return $1 if regExp =~ item.note
  35.     return 0
  36.   end
  37. end
  38.  
  39. if ZERO_SKILL_PRIORITY::MODIFY
  40.   module DataManager
  41.     class << self
  42.       alias :zero_load_database :load_database
  43.       def load_database
  44.         zero_load_database
  45.         $data_skills.each { |item|
  46.           next if item.nil?
  47.           if ZERO_SKILL_PRIORITY.getPriority(item) == ZERO_SKILL_PRIORITY::PRIORITY
  48.             item.name = ZERO_SKILL_PRIORITY::TEXT + item.name
  49.           end
  50.         }
  51.       end
  52.     end
  53.   end
  54. end
  55.  
  56. class Window_SkillList < Window_Selectable
  57.   alias zero_make_item_list make_item_list
  58.   def make_item_list
  59.     zero_make_item_list
  60.     @data.sort! { |a,b|
  61.       ZERO_SKILL_PRIORITY.getPriority(b).to_i <=> ZERO_SKILL_PRIORITY.getPriority(a).to_i
  62.     }
  63.   end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement