Seiruki - Categorize Item Scene Mod

Discussion in 'RGSSx Script Support' started by Roninator2, Aug 13, 2019.

Thread Status:
Not open for further replies.
  1. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,598
    Likes Received:
    349
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    https://www.rpgmakercentral.com/topic/661-vxa-categorize-item-scene/

    I've been working on figuring out how to change this script to help another member on another forum.
    TheoAllen has helped me to figure out some of the problem, but I haven't been able to finish it.
    I did make some progress, but my knowledge of ruby is certainly low.

    Essentially the request was to hide item categories if there were no items for that specific category.

    The code given by Theoallen which works for the default categories is
    Code:
    CategoryConditions = {
    :item => lambda { !$game_party.items.empty? && $game_party.items.any? {|item| !item.key_item? }},
    :weapon => lambda { !$game_party.weapons.empty? },
    :armor => lambda { !$game_party.armors.empty? },
    :key_item => lambda { !$game_party.items.empty? && $game_party.items.any? {|item| item.key_item? }},
    :all_item => lambda { !$game_party.all_items.empty? },
    }
    for the make command section
    Code:
     alias icat_make_command_list make_command_list
       def make_command_list
      ICAT::VISIBLE_CATEGORY_INDEX.each { |symbol, label|
        add_command(label, symbol) if ICAT::CategoryConditions[symbol].call
      }
     end
    
    From here there are two problems,

    The custom categories that can be added to any item, weapon or armor
    and the help description. The help text doesn't line up when categories are removed.

    I tried this for custom categories but it doesn't really work, again lack of knowledge.
    Code:
    :potion => lambda { !$game_party.all_items.empty? && $game_party.all_items.any? {|item| item.find_category } },
    :ammunition => lambda { !$game_party.all_items.empty? && $game_party.all_items.any? {|item| item.find_category } },
    
    linking to this section i added in under baseitem
    Code:
     def find_category
      self.note.split(/[\r\n]+/).each { |line|
        if line =~ ICAT::Regexp::BaseItem::CATEGORY
        c = ICAT::CATEGORY_IDENTIFIER.key($1)
        return c if c != nil
        end
      }
     end
    
    I did try using item_category in BaseItem, but the categories show up when an item is available but not for that category.

    Thanks for any advice.

    **edit...

    I just got the custom categories to work.
    Code:
    :potion => lambda { $game_party.all_items.any? {|item| item.find_category == :potion} },
    :ammunition => lambda { $game_party.all_items.any? {|item| item.find_category == :ammunition} },
    
    Now if someone can advise with the help text indexing.
     
    Last edited: Aug 13, 2019
    #1
  2. KK20

    KK20 Just some XP Scripter Veteran

    Messages:
    76
    Likes Received:
    35
    Location:
    Orange County, California
    First Language:
    English
    Primarily Uses:
    RMXP
    Change the configuration for the descriptions to match VISIBLE_CATEGORY_INDEX:
    Code:
    CATEGORY_DESCRIPTION = {
      #:item => "Viewing basic items.",
      :weapon => "Viewing attack-type items for use in battles.",
      :armor => "Viewing head, body, arm and leg equipment.",
      :key_item => "Viewing important items.",
      :all_item => "Viewing all items.",
      :potion => "Viewing potions.",
      :ammunition => "Viewing ammunition.",
    }
    
    And replace the methods inside class ICAT_WindowItemCategory with these:
    Code:
      def initialize
        @category_list = []
        super
        self.z = 1000
        self.index = 0
      end
    
      def update_help
        @help_window.set_text(ICAT::CATEGORY_DESCRIPTION[@category_list[self.index]])
      end
    
      alias icat_make_command_list make_command_list
      def make_command_list
        @category_list.clear
        ICAT::VISIBLE_CATEGORY_INDEX.each do |symbol, label|
          add_command(label, symbol)
          @category_list << symbol
        end
      end
    
    Untested
     
    Last edited: Aug 14, 2019
    #2
  3. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,598
    Likes Received:
    349
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Undefined method <<
     
    #3
  4. KK20

    KK20 Just some XP Scripter Veteran

    Messages:
    76
    Likes Received:
    35
    Location:
    Orange County, California
    First Language:
    English
    Primarily Uses:
    RMXP
    In the initialize method, move @category_list above super
     
    #4
  5. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,598
    Likes Received:
    349
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    Cannot convert Symbol to integer
     
    #5
  6. KK20

    KK20 Just some XP Scripter Veteran

    Messages:
    76
    Likes Received:
    35
    Location:
    Orange County, California
    First Language:
    English
    Primarily Uses:
    RMXP
    Did you not change CATEGORY_DESCRIPTION to a hash (and left it as an array)? Notice the curly braces in my post.
     
    #6
  7. Roninator2

    Roninator2 Gamer Veteran

    Messages:
    1,598
    Likes Received:
    349
    Location:
    Canada
    First Language:
    English
    Primarily Uses:
    RMVXA
    I just thought of that and changed it to try it out. then refreshed the thread and saw your reply.
    It fixed the error. But I think there is still an issue. doing some testing now.

    Yep, there was a problem. It was adding the category even if there were no items.
    I added in the condition for the previous add command check and it works
    Code:
        @category_list << symbol if ICAT::CategoryConditions[symbol].call
    
    Script mod complete.
    https://www.rpgmakercentral.com/topic/42160-categorize-item-scene/
     
    Last edited: Aug 14, 2019
    #7
  8. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    11,784
    Likes Received:
    11,822
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMVXA

    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

     
    #8
Thread Status:
Not open for further replies.

Share This Page