Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Subdividing the "Items" section in the menu. Such as in "Utopian Chaos".

Alright so basically what I would like is this. When the player selects "Item" in the menu, it brings up several new choices: "General", "Recipe", "Creation", "Event", and "Cards".

Then, when you select one of those choices, it brings you to the typical item menu, but containing only  the items of that subdivision (eg. Potions in "General", keys in "event")

I know this script exists, since I've seen it in the game Utopian Chaos. I'm just not sure what to search for (I've tried "item menu" with no luck).

Thanks in advance
 
It seems to work fine, even with SDK. My only problem is this:

For some reason, when I press left or right (or up and down if I switch it to vertical) it skips one category and goes to the next. For example, there are 6 default categories, listed below:
General, Battle, Armor, Weapons, Key, All
It starts at General. I press right once, and it goes to Armor. I press it again, it goes to Key. If I press it again, it doesn't skip anything and goes to All. But then when I press left, it skips one again.

Is there a reason for this? A solution? Thanks in advance
 

poccil

Sponsor

I've made a script that does what you want.  The script code begins:

Code:
def pbCommands(commands,x,y)
 width=0
 dummy=Bitmap.new(1,1)
 for cmd in commands
  width=[width,dummy.text_size(cmd).width].max
 end
 width+=48
 window = Window_Command.new(width,commands)
 window.index=0
 window.x=x
 window.y=y
 window.z=200
 ret=-1
 loop do
  Graphics.update
  Input.update
  if Input.trigger?(Input::B)
   $game_system.se_play($data_system.cancel_se)
   ret=-1
   break
  elsif Input.trigger?(Input::C)
   $game_system.se_play($data_system.decision_se)
   ret=window.index
   break
  end
  window.update
 end
 window.dispose
 return ret
end

class Scene_Item_Category < Scene_Item
  def initialize(category)
    @category=category
  end
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @item_window = Window_Item_Category.new(@category)
    # Associate help window
    @item_window.help_window = @help_window
    # Make target window (set to invisible / inactive)
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @item_window.dispose
    @target_window.dispose
  end
end

class Window_Item_Category < Window_Item
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def itemCategory(itemType,item)
   return 0
  end
  def initialize(category)
    super()
    @column_max = 2
    @category=category
    refresh
    self.index = 0
    # If in battle, move window to center of screen
    # and make it semi-transparent
    if $game_temp.in_battle
      self.y = 64
      self.height = 256
      self.back_opacity = 160
    end
  end
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    # Add item
    for i in 1...$data_items.size
      if $game_party.item_number(i) > 0 && itemCategory(0,i)==@category
        @data.push($data_items[i])
      end
    end
    # Also add weapons and armors if outside of battle
    unless $game_temp.in_battle
      for i in 1...$data_weapons.size
        if $game_party.weapon_number(i) > 0 && itemCategory(1,i)==@category
          @data.push($data_weapons[i])
        end
      end
      for i in 1...$data_armors.size
        if $game_party.armor_number(i) > 0 && itemCategory(2,i)==@category
          @data.push($data_armors[i])
        end
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
end

Then modify the script section Scene_Menu by replacing the case starting at line 124 with the following:

Code:
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        command=pbCommands(["General", "Recipe", "Creation", "Event", "Cards"],16,16)
        if command>=0
          $scene = Scene_Item_Category.new(command)
        end
      when 1  # skill
        # Play decision SE

The itemCategory function found in the new Window_Item_Category class determines a category for each item.  By default, it looks like this:

Code:
  def itemCategory(itemType,item)
   return 0
  end

It has two parameters: _itemType_, which is the type of item (0=item; 1=weapon; 2=armor); and _item_, which is the item ID.  In your case, the return value should be 0 for general items, 1 for recipe items, 2 for creation items, 3 for event items, and 4 for card items.  The default function assumes a return value of 0 (all items are general).
 
Unfortunately I had no luck with the script, it seems. I can't seem to find a Window_item_category class, just Window_Item and whatnot.

The KGC item grouping script seemed to be able to get what I want without altering other scripts. I'd just label the item with an element tag for it to get into a certain subdivision. The script's above if you wanna talk a look at it, I guess. The only problem with it is that it skips a category when you press left or right. I could technically fix this by having a blank category between each real category, but it seems like that'd be a waste to say the least.

Thanks for the help, though.
 

poccil

Sponsor

You must have overlooked my script.  The class Window_Item_Category is defined in the big block of script code above.  I should have mentioned that the itemCategory function is defined there and that Window_Item_Category is not part of the default scripts.  Please look again.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top