The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: cozziekuns on June 01, 2010, 09:03:45 PM

Title: Simple Sort Inventory
Post by: cozziekuns on June 01, 2010, 09:03:45 PM
Simple Sort Inventory
Version: 2.0
Author: cozziekuns
Date: August 7, 2011

Version History



Planned Future Versions


Description


Like in Tales of Phantasia, this inventory allows you to sort your items into various categories.

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi46.tinypic.com%2Fwtdtaw.png&hash=9323f0b1812202dd6eb8d324f5dbe08baba3142c)

Instructions

See header.

Script


Code: [Select]
#===============================================================================

# Cozziekuns Simple Sort Inventory
# Last Date Updated: 08/07/11
#
# Like in Tales of Phantasia, this inventory allows you to sort your items in
# the categories: All, Items, Weapons and Armours.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 06/01/10 - Created Script.
# o 06/01/10 - Updated with Modern Algebra's recommendations.
# o 06/01/10 - Once again updated with Modern Algebra's recommendations.
# o 08/27/10 - Updated with Scrolling support. Thanks kawagiri for the idea, and
#              Modern Algebra for some help.
# o 09/06/10 - Updated with some bugfixing. Thanks Fizzly for finding that out.
# o 07/08/11 - Fixed the special prime categories; now you can take out item,
#              weapon, all and armours. Also added an addon for Modern Algebra's
#              Item Instances Base; if you are using it, category 4 will contain
#              all instance items. If you are using it and you do not want this,
#              simply do not have a category 4.
#===============================================================================
# What's to come?
# -----------------------------------------------------------------------------
# o Nothing! Suggest something.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# Change the modules to your liking. The "hard" parts have instructions of their
# own.
#===============================================================================

$imported = {} if $imported == nil
$imported["CozSimplSortInvent"] = true

module COZZIEKUNS
  module SSI
    CATEGORY_TEXT = "Category:"
   
#===============================================================================
# Extra Item Categories (Inspired by Modern Algebra)
# ------------------------------------------------------------------------------
# How should I go about explaining something like this? Well, basically, each
# item in the hash represents a certain category. For example, the first hash we
# see here is:
#
# 0 => [144, "All", false]
#
# The syntax of this is:
#
# Category ID => [Icon Number, Text, Prime]
#
# Probably the most important part, the category ID is the number you want to
# put into the notebox that the item contains. For example, if you wanted to
# make the item "World Map" into a key item, simply add the text:
#
# \item_category[4]
#
# into the notebox. Note that numbers 0, 1, 2, and 3 are special. They're prime
# categories. Sound special right? They correspond to the categories: All,
# Items, Weapons and Armours respectively.
#
# Last, but not least, is the "Prime" function (inspired by Kyraiki). Setting
# this to "true" means that anything in the prime category will not show up in
# the item, weapon armour or instance (if you have MA's Item Instances Base {try
# saying that five times fast}) categories. You can set if you want it to show
# up in all.
#===============================================================================
    MOD_ALG_ITEM_CATEGORIES = {  # Make sure they are in order!!!
   
      0 => [144, "All", false],
      1 => [64, "Items", false],
      2 => [26, "Weapons", false],
      3 => [40, "Armours", false],
      4 => [90, "Instance", true],
      5 => [80, "Key Items", false],
      6 => [92, "Filler", false],
      7 => [32, "Scrolling", false],
    }
   
    MOD_ALG_ITEM_CATEGORY_WIDTH = 220 # How wide you want your text window.
    KYRIAKI_ALL_CATEOGRY_PRIME = false # If you want prime key items to show up in the all window.
    MAX_NUMBER = (544 - MOD_ALG_ITEM_CATEGORY_WIDTH) / 54 # The maximum number of icons that will fit.
   
  end
end

#==============================================================================
# ** RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Cozziekuns Category Index
  #--------------------------------------------------------------------------
  def coz_modalg_category_index
    @coz_modalg_category_index = 0
    if self.note[/\\item_category\[(\d+)]/i] != nil
      @coz_modalg_category_index = $1.to_i
    end
  return @coz_modalg_category_index
  end
end

#==============================================================================
# ** Window_Item
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias coz_modalg_ssi_refresh refresh
  def refresh(sort_index = 0)
   @sort_index = sort_index
   coz_modalg_ssi_refresh
 end
  #--------------------------------------------------------------------------
  # * Whether or not to include in item list
  #--------------------------------------------------------------------------
  alias coz_modalg_ssi_include? include?
  def include?(item)
    val = coz_modalg_ssi_include?(item)
    return false if !val
    case @sort_index
    when 0
      unless COZZIEKUNS::SSI::KYRIAKI_ALL_CATEOGRY_PRIME
        return !COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
      else
        return true
      end
    when 1
      if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
        return false
      else
        return item.is_a?(RPG::Item)
      end
    when 2
      if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
        return false
      else
        return item.is_a?(RPG::Weapon)
      end
    when 3
      if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
        return false
      else
        return item.is_a?(RPG::Armor)
      end
    when 4
      if not $imported["MAInstanceItemsBase"]
        return item.coz_modalg_category_index == @sort_index
      else
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.instance_based?
        end
      end
    when 5..999
      return item.coz_modalg_category_index == @sort_index
    end
  end
end
 
#==============================================================================
# ** Window_ItemCategory
#==============================================================================

class Window_ItemCategory < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    @category_string = COZZIEKUNS::SSI::CATEGORY_TEXT
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @category_string, 0)
    self.contents.font.color = normal_color
    for key in @item_categories.keys.sort
      if @sort_index == key
        self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @item_categories[key][1], 2)
        break
      end
    end
  end
end

#==============================================================================
# ** Window_ItemSort
#==============================================================================

class Window_ItemSort < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    @ox = 0
    if COZZIEKUNS::SSI::MAX_NUMBER < COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES.size
      self.contents = Bitmap.new(self.width - 32 + ((COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES.size - COZZIEKUNS::SSI::MAX_NUMBER) * 54), self.height - 32)
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    self.contents.clear
    for i in 0...@item_categories.size
      key = @item_categories.keys.sort[i]
      @icon_x = 0 + (i * ((544 - @item_categories_width) / @item_categories.size))
      if @item_categories.size < COZZIEKUNS::SSI::MAX_NUMBER
        draw_item(key, i)
      else
        draw_items(key, i)
      end
      if @sort_index == key
        if @item_categories.size < COZZIEKUNS::SSI::MAX_NUMBER
          draw_icon(@item_categories[key][0], @icon_x, 0, true)
        else
          draw_icon(@item_categories[key][0], i * 54, 0, true)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #--------------------------------------------------------------------------
  def draw_item(index, id)
    icons_x = (544 - @item_categories_width) / @item_categories.size
    draw_icon(@item_categories[index][0], id * icons_x, 0, false)
  end
  #--------------------------------------------------------------------------
  # * Draw Items
  #--------------------------------------------------------------------------
  def draw_items(index, id)
    draw_icon(@item_categories[index][0], id * 54, 0, false)
  end
end

#==============================================================================
# ** Scene_Item
#==============================================================================

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @item_window = Window_Item.new(0, 112, 544, 304)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.active = false
    @category_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    @category_window = Window_ItemCategory.new(544 - @category_width, 56, @category_width)
    @sort_window = Window_ItemSort.new(0, 56, 544 - @category_width)
    @target_window = Window_MenuStatus.new(0, 0)
    @sort_index = 0
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    hide_target_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias coz_ssi_terminate terminate
  def terminate
    super
    coz_ssi_terminate
    @sort_window.dispose
    @category_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Update Frame
  #--------------------------------------------------------------------------
  alias coz_ssi_update update
  def update
    super
    coz_ssi_update
    @sort_window.update
    @category_window.update
  end
  #--------------------------------------------------------------------------
  # * Update Item Selection
  #--------------------------------------------------------------------------
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      @item = @item_window.item
      if @item != nil
        $game_party.last_item_id = @item.id
      end
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        determine_item
      else
        Sound.play_buzzer
      end
    elsif Input.trigger?(Input::Y)
      @sort_index += 1
      @sort_index %= @item_categories.size
      if @sort_index != 0
        if @item_categories.size > COZZIEKUNS::SSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSI::MAX_NUMBER - 1
          @sort_window.ox += 54
        end
      else
        @sort_window.ox = 0
      end
      @category_window.refresh(@item_categories.keys.sort[@sort_index])
      @sort_window.refresh(@item_categories.keys.sort[@sort_index])
      @item_window.refresh(@item_categories.keys.sort[@sort_index])
      @item_window.index = 0
      Sound.play_cursor
    elsif Input.trigger?(Input::X)
      @sort_index -= 1
      @sort_index %= @item_categories.size
      if @sort_index + 1 == @item_categories.size
        @sort_window.ox += 54 * (@item_categories.size - COZZIEKUNS::SSI::MAX_NUMBER)
      else
        if @item_categories.size > COZZIEKUNS::SSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSI::MAX_NUMBER - 2
          @sort_window.ox -= 54
        end
      end
      @category_window.refresh(@item_categories.keys.sort[@sort_index])
      @sort_window.refresh(@item_categories.keys.sort[@sort_index])
      @item_window.refresh(@item_categories.keys.sort[@sort_index])
      @item_window.index = 0
      Sound.play_cursor
    end
  end
end

Credit



Thanks


Support


Just post down here.

Known Compatibility Issues

Probably won't work with any other inventory scripts (e.g, MA's Grid Inventory or MA's Limited Inventory). If anyone wants one, I could probably write a compatibility fix or something.
Title: Re: Simple Sort Inventory
Post by: modern algebra on June 01, 2010, 09:15:29 PM
Well, it looks pretty nice. I suggest you write an addon that allows the user to define categories as well. Maybe have a little database like:

Code: [Select]
hash = {
  1 => [100, "Healing Items"],
  2 => [45, "Poisons"],
  n => [icon_index, "category name"]
}

And then they could add items to those categories by some code in the notebox, like:
Code: [Select]
\category[n]

And they could put each item into as many categories as they want.

Anyway, that sort of feature probably isn't necessary and may make for some clutter, but it's an easy way to add some customizability to the script, and it could be useful if someone wanted to add a Key Items category, for instance, or an Ingredients category if they have a tailoring system.

Granted, if you did that, you might also want to add an option to reduce the width of the "Category: name" box, so they could make the other box smaller or larger as they need to.

Anyway, all that is superfluous; the script is nice as it is :)
Title: Re: Simple Sort Inventory
Post by: cozziekuns on June 01, 2010, 09:23:52 PM
That's a pretty good idea. I might implement it in later.

Thanks for the feedback!
Title: Re: Simple Sort Inventory
Post by: modern algebra on June 01, 2010, 09:26:24 PM
Looking at the code, I don't think you made good use of the infrastructure in Window_Item. Note that Window_Item has this method:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Whether or not to include in item list
  #     item : item
  #--------------------------------------------------------------------------
  def include?(item)
    return false if item == nil
    if $game_temp.in_battle
      return false unless item.is_a?(RPG::Item)
    end
    return true
  end

It would make a lit more sense to edit that rather than overwrite the refresh method. Think this instead:

Code: [Select]
  alias new_include_item include_item?
  def include_item? (item)
    val = new_include_item (item)
    return false if !val
    return case @sort_index
    when 0 then true
    when 1 then item.is_a? (RPG::Item)
    when 2 then item.is_a? (RPG::Weapon)
    when 3 then item.is_a? (RPG::Armor)
    end
  end

And you would then only have to find some way to pass @sort_index to Window_Item, which you could do either by aliasing refresh or adding it as an accessor to the class and changing it right before you call the refresh method.

It would also get rid of the need to make those methods in Game_Party that return weapons, armours, etc...


It is still a very nice script as it is, so congratulations.
Title: Re: Simple Sort Inventory
Post by: cozziekuns on June 01, 2010, 09:30:05 PM
Yeah, my method isn't the best method out there. Looks like I still have lots to learn.
Title: Re: Simple Sort Inventory
Post by: cozziekuns on June 02, 2010, 02:00:02 AM
'Kay, I updated it to fit with the code you wrote for me. Thanks a lot, Modern!
Title: Re: Simple Sort Inventory
Post by: modern algebra on June 02, 2010, 02:16:34 AM
It's looking good. I have another little tip though :P Not really, this one makes no difference, but you might find it useful when you're scripting:

Code: [Select]
if x == y
  return true
else
  return false
end

is the same thing as:

Code: [Select]
return (x == y)

Not a big deal of course, but it can often be a clean way to do a check like that.
Title: Re: Simple Sort Inventory
Post by: Kyriaki on June 19, 2010, 07:52:25 AM
I really love this script, it's super adorable and feeds my addiction for meticulous organization!

But I was wondering if there were any future plans to separate the 'prime categories' or if it can even be done easily? You know, so that Key Items for example won't show up in the Items category or Accessories in the Armor category. Sorry, I don't really know anything about scripting, hehe. ^^; 
Title: Re: Simple Sort Inventory
Post by: Sophist on June 19, 2010, 08:51:03 AM
Excellent script. Be proud.
Title: Re: Simple Sort Inventory
Post by: cozziekuns on June 19, 2010, 05:11:00 PM
But I was wondering if there were any future plans to separate the 'prime categories' or if it can even be done easily? You know, so that Key Items for example won't show up in the Items category or Accessories in the Armor category. Sorry, I don't really know anything about scripting, hehe. ^^; 

That's a pretty good idea. Do you want it to also belong in the All category?
Title: Re: Simple Sort Inventory
Post by: cozziekuns on June 20, 2010, 12:21:42 AM
* Legit Double Post *

Ok, I updated it to Version 1.2 to fit your needs Kyriaki. I also made a boolean switch for whether or not you want to include Key Items in the All category.
Title: Re: Simple Sort Inventory
Post by: Kyriaki on June 20, 2010, 01:54:41 AM
Thank you so much and I am sorry I could not reply sooner! This does exactly what I wanted and works perfectly!

Oh...maybe not. The "KYRIAKI_ALL_CATEOGRY_PRIME = true/false" switch, was that meant to show the new 'prime categories' in 'All' or just items/weapons/armor? When I set it to false everything does not show including items/weapons/armor, but when I set it to true only items/weapon/armor will show, not the newer 'prime categories'.
Title: Re: Simple Sort Inventory
Post by: cozziekuns on June 20, 2010, 11:34:35 PM
Ok, I updated it so it should work...

Tell me if you find any bugs.
Title: Re: Simple Sort Inventory
Post by: Kyriaki on June 21, 2010, 01:15:06 AM
Yay!! Thank you for all your time and patience!! It's absolutely wonderful~!
Title: Re: Simple Sort Inventory
Post by: cozziekuns on August 27, 2010, 11:22:24 PM
Upgraded to Version 1.3, this includes scrolling categories. Thanks for kawagiri for the idea and Modern Algebra for some helping out.
Title: Re: Simple Sort Inventory
Post by: Fizzly on September 06, 2010, 04:07:16 PM
Okay, this is cool! :) But found little bug... I defined text window width to 160, have 7 categories (0-6):
http://ifotos.pl/img/sample2_wqhnqa.JPG
While I'm on first category (all) and push the next button, everything is fine (all 7 categories are visible=no scrolling needed):
http://ifotos.pl/img/sample3_wqhepn.JPG
And the problem is with scrolling back. While pushing previous button (from "All" category"), the panel is scrolling, but there is really no need... I mean this:
http://ifotos.pl/img/sample1_wqhehp.JPG

Could you please fix this? I also checked the raw version of script, without any changes, and the problem still occurs. Press the previous (shift) button in "all" inventory. You'll see the empty category square on the right side (the "?" one on the pic above).

Title: Re: Simple Sort Inventory
Post by: cozziekuns on September 06, 2010, 04:53:10 PM
Thanks for finding that. Should be fixed. Please retrieve the script from the raw script, and not the demo.
Title: Re: Simple Sort Inventory
Post by: Fizzly on September 06, 2010, 05:04:42 PM
Thank you so much!  ^-^

Edit: Now it works fine for me (7 categories), but I'm afraid the 5 categories still have the same problem ^ ^' Check this out.
Title: Re: Simple Sort Inventory
Post by: cozziekuns on September 06, 2010, 06:54:21 PM
Fixed again, neglected two lines of code :P
Title: Re: Simple Sort Inventory
Post by: Neko Hibiki on October 26, 2010, 08:02:19 PM

The instructions aren't clear at all now.

I don't understand how to do this.

Could you give some examples of items?

Title: Re: Simple Sort Inventory
Post by: cozziekuns on October 26, 2010, 10:46:30 PM
IIRC, there are some in the demo.

E.g Almanac, is specific only to item cateogory four, which is symbolised by the text in the notebox : /item_category[4]
Title: Re: Simple Sort Inventory
Post by: ZeroManArmy on November 07, 2010, 05:53:04 AM
Some small and nice fixes.

1. Aligns the text for the Description so that way instead of being on the left it as right after "Description:"

Replace this line
Code: [Select]
self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @item_categories[i][1], 2)

With this one
Code: [Select]
self.contents.draw_text(95, 0, @item_categories_width - 40, WLH, @item_categories[i][1], 0)


2. This edit just makes its so that instead of when you press Shift it goes to the right instead of the left.

Replace this line
Code: [Select]
@sort_index -= 1

With this one
Code: [Select]
@sort_index += 1
Title: Re: Simple Sort Inventory
Post by: Infinate X on November 30, 2010, 11:31:27 PM
This is AWESOME!!! :D       :tpg: :-\ :o ??? ::) :P :o :D ;) :=: :zwink:
Title: Re: Simple Sort Inventory
Post by: whofreak97 on May 08, 2011, 06:25:21 PM
Hello, i hae a problem with ths script. I am getting a SyntaxError in Line 315. Could you help me.
Title: Re: Simple Sort Inventory
Post by: pacdiggity on May 08, 2011, 08:32:17 PM
Yes, copy this script from here.
Code: [Select]
#===============================================================================

# Cozziekuns Simple Sort Inventory
# Last Date Updated: 09/06/10
#
# Like in Tales of Phantasia, this inventory allows you to sort your items in
# the categories: All, Items, Weapons and Armours.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 06/01/10 - Created Script.
# o 06/01/10 - Updated with Modern Algebra's recommendations.
# o 06/01/10 - Once again updated with Modern Algebra's recommendations.
# o 08/27/10 - Updated with Scrolling support. Thanks kawagiri for the idea, and
#              Modern Algebra for some help.
# o 09/06/10 - Updated with some bugfixing. Thanks Fizzly for finding that out.
#===============================================================================
# What's to come?
# -----------------------------------------------------------------------------
# o Nothing! Suggest something.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# Change the modules to your liking. The "hard" parts have instructions of their
# own.
#===============================================================================

$imported = {} if $imported == nil
$imported["CozSimplSortInvent"] = true

module COZZIEKUNS
  module SSI
    CATEGORY_TEXT = "Category:"
   
#===============================================================================
# Extra Item Categories (Inspired by Modern Algebra)
# ------------------------------------------------------------------------------
# How should I go about explaining something like this? Well, basically, each
# item in the hash represents a certain category. For example, the first hash we
# see here is:
#
# 0 => [144, "All", false]
#
# The syntax of this is:
#
# Category ID => [Icon Number, Text, Prime]
#
# Probably the most important part, the category ID is the number you want to
# put into the notebox that the item contains. For example, if you wanted to
# make the item "World Map" into a key item, simply add the text:
#
# \item_category[4]
#
# into the notebox. Note that numbers 0, 1, 2, and 3 are special. They're prime
# categories. Sound special right? Not really, this just means you have to have
# them in the inventory for this script to work. I could've gotten rid of them,
# but that would've just given more work on your part (and mine), so bear with
# them, please. Icon Numbers and Text are pretty self explanatory.
#
# Last, but not least, is the "Prime" function (inspired by Kyraiki). Setting
# this to "true" means that anything in the prime category will not show up in
# the item, weapon or armour categories. You can set if you want it to show up
# in all.
#===============================================================================
    MOD_ALG_ITEM_CATEGORIES = {
   
      0 => [144, "All", false],
      1 => [64, "Items", false],
      2 => [26, "Weapons", false],
      3 => [40, "Armours", false],
      4 => [80, "Key Items", true],
      5 => [90, "Filler", false],
      6 => [92, "Scrolling", false],
      7 => [32, "Scrolling", false],
    }
   
    MOD_ALG_ITEM_CATEGORY_WIDTH = 220 # How wide you want your text window.
    KYRIAKI_ALL_CATEOGRY_PRIME = false # If you want prime key items to show up in the all window.
    MAX_NUMBER = (544 - MOD_ALG_ITEM_CATEGORY_WIDTH) / 54 # The maximum number of icons that will fit.
  end
end

#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
#  The superclass of all states.
#==============================================================================

class RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Cozziekuns Category Index
  #--------------------------------------------------------------------------
  def coz_modalg_category_index
    @coz_modalg_category_index = 0
    if self.note[/\\item_category\[(\d+)]/i] != nil
      @coz_modalg_category_index = $1.to_i
    end
  return @coz_modalg_category_index
  end
end

#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays a list of inventory items for the item screen, etc.
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias coz_modalg_ssi_refresh refresh
  def refresh(sort_index = 0)
   @sort_index = sort_index
   coz_modalg_ssi_refresh
 end
  #--------------------------------------------------------------------------
  # * Whether or not to include in item list
  #     item : item
  #--------------------------------------------------------------------------
  alias coz_modalg_ssi_include? include?
  def include?(item)
    val = coz_modalg_ssi_include?(item)
    return false if !val
    return case @sort_index
      when 0
        unless COZZIEKUNS::SSI::KYRIAKI_ALL_CATEOGRY_PRIME
          if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
            return false
          else
            return true
          end
        else
          return true
        end
      when 1
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.is_a?(RPG::Item)
        end
      when 2
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.is_a?(RPG::Weapon)
        end
      when 3
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.is_a?(RPG::Armor)
        end
      when 4..999
        return item.coz_modalg_category_index == @sort_index
      end
    end
  end
 
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
#  This window displays what type of item is being displayed.
#==============================================================================

class Window_ItemCategory < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    @category_string = COZZIEKUNS::SSI::CATEGORY_TEXT
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @category_string, 0)
    self.contents.font.color = normal_color
    for i in 0...@item_categories.size
      if @sort_index == i
        self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @item_categories[i][1], 2)
      end
    end
  end
end

#==============================================================================
# ** Window_ItemSort
#------------------------------------------------------------------------------
#  This window displays what type of item is being displayed.
#==============================================================================

class Window_ItemSort < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    @ox = 0
    if COZZIEKUNS::SSI::MAX_NUMBER < COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES.size
      self.contents = Bitmap.new(self.width - 32 + ((COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES.size - COZZIEKUNS::SSI::MAX_NUMBER) * 54), self.height - 32)
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    self.contents.clear
    for i in 0...@item_categories.size
      @icon_x = 0 + (i * ((544 - @item_categories_width) / @item_categories.size))
      if @item_categories.size < COZZIEKUNS::SSI::MAX_NUMBER
        draw_item(i)
      else
        draw_items(i)
      end
      if @sort_index == i
        if @item_categories.size < COZZIEKUNS::SSI::MAX_NUMBER
          draw_icon(@item_categories[i][0], @icon_x, 0, true)
        else
          draw_icon(@item_categories[i][0], i * 54, 0, true)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    icons_x = (544 - @item_categories_width) / @item_categories.size
    draw_icon(@item_categories[index][0], index * icons_x, 0, false)
  end
  #--------------------------------------------------------------------------
  # * Draw Items
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_items(index)
    draw_icon(@item_categories[index][0], index * 54, 0, false)
  end
end

#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs the item screen processing.
#==============================================================================

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @item_window = Window_Item.new(0, 112, 544, 304)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.active = false
    @category_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    @category_window = Window_ItemCategory.new(544 - @category_width, 56, @category_width)
    @sort_window = Window_ItemSort.new(0, 56, 544 - @category_width)
    @target_window = Window_MenuStatus.new(0, 0)
    @sort_index = 0
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    hide_target_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias coz_ssi_terminate terminate
  def terminate
    super
    coz_ssi_terminate
    @sort_window.dispose
    @category_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Update Frame
  #--------------------------------------------------------------------------
  alias coz_ssi_update update
  def update
    super
    coz_ssi_update
    @sort_window.update
    @category_window.update
  end
  #--------------------------------------------------------------------------
  # * Update Item Selection
  #--------------------------------------------------------------------------
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      @item = @item_window.item
      if @item != nil
        $game_party.last_item_id = @item.id
      end
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        determine_item
      else
        Sound.play_buzzer
      end
    elsif Input.trigger?(Input::Y)
      @sort_index += 1
      @sort_index %= @item_categories.size
      if @sort_index != 0
        if @item_categories.size > COZZIEKUNS::SSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSI::MAX_NUMBER - 1
          @sort_window.ox += 54
        end
      else
        @sort_window.ox = 0
      end
      @category_window.refresh(@sort_index)
      @sort_window.refresh(@sort_index)
      @item_window.refresh(@sort_index)
      @item_window.index = 0
      Sound.play_cursor
    elsif Input.trigger?(Input::A)
      @sort_index -= 1
      @sort_index %= @item_categories.size
      if @sort_index + 1 == @item_categories.size
        @sort_window.ox += 54 * (@item_categories.size - COZZIEKUNS::SSI::MAX_NUMBER)
      else
        if @item_categories.size > COZZIEKUNS::SSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSI::MAX_NUMBER - 2
          @sort_window.ox -= 54
        end
      end
      @category_window.refresh(@sort_index)
      @sort_window.refresh(@sort_index)
      @item_window.refresh(@sort_index)
      @item_window.index = 0
      Sound.play_cursor
    end
  end
end
If it still doesn't work, it's probably an error on your end.
Title: Re: Simple Sort Inventory
Post by: whofreak97 on June 04, 2011, 10:32:19 AM
Thanks, it works. But i want to know how to change the controls to go from category to category.
Title: Re: Simple Sort Inventory
Post by: pacdiggity on June 04, 2011, 11:07:59 AM
Code: [Select]
#===============================================================================

# Cozziekuns Simple Sort Inventory
# Last Date Updated: 09/06/10
#
# Like in Tales of Phantasia, this inventory allows you to sort your items in
# the categories: All, Items, Weapons and Armours.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 06/01/10 - Created Script.
# o 06/01/10 - Updated with Modern Algebra's recommendations.
# o 06/01/10 - Once again updated with Modern Algebra's recommendations.
# o 08/27/10 - Updated with Scrolling support. Thanks kawagiri for the idea, and
#              Modern Algebra for some help.
# o 09/06/10 - Updated with some bugfixing. Thanks Fizzly for finding that out.
#===============================================================================
# What's to come?
# -----------------------------------------------------------------------------
# o Nothing! Suggest something.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# Change the modules to your liking. The "hard" parts have instructions of their
# own.
#===============================================================================

$imported = {} if $imported == nil
$imported["CozSimplSortInvent"] = true

module COZZIEKUNS
  module SSI
    CATEGORY_TEXT = "Category:"
   
#===============================================================================
# Extra Item Categories (Inspired by Modern Algebra)
# ------------------------------------------------------------------------------
# How should I go about explaining something like this? Well, basically, each
# item in the hash represents a certain category. For example, the first hash we
# see here is:
#
# 0 => [144, "All", false]
#
# The syntax of this is:
#
# Category ID => [Icon Number, Text, Prime]
#
# Probably the most important part, the category ID is the number you want to
# put into the notebox that the item contains. For example, if you wanted to
# make the item "World Map" into a key item, simply add the text:
#
# \item_category[4]
#
# into the notebox. Note that numbers 0, 1, 2, and 3 are special. They're prime
# categories. Sound special right? Not really, this just means you have to have
# them in the inventory for this script to work. I could've gotten rid of them,
# but that would've just given more work on your part (and mine), so bear with
# them, please. Icon Numbers and Text are pretty self explanatory.
#
# Last, but not least, is the "Prime" function (inspired by Kyraiki). Setting
# this to "true" means that anything in the prime category will not show up in
# the item, weapon or armour categories. You can set if you want it to show up
# in all.
#===============================================================================
    MOD_ALG_ITEM_CATEGORIES = {
   
      0 => [144, "All", false],
      1 => [64, "Items", false],
      2 => [26, "Weapons", false],
      3 => [40, "Armours", false],
      4 => [80, "Key Items", true],
      5 => [90, "Filler", false],
      6 => [92, "Scrolling", false],
      7 => [32, "Scrolling", false],
    }
   
    MOD_ALG_ITEM_CATEGORY_WIDTH = 220 # How wide you want your text window.
    KYRIAKI_ALL_CATEOGRY_PRIME = false # If you want prime key items to show up in the all window.
    MAX_NUMBER = (544 - MOD_ALG_ITEM_CATEGORY_WIDTH) / 54 # The maximum number of icons that will fit.
    RIGHT_BUTTON = Input::Y
    LEFT_BUTTON = Input::X
  end
end

#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
#  The superclass of all states.
#==============================================================================

class RPG::BaseItem
  #--------------------------------------------------------------------------
  # * Cozziekuns Category Index
  #--------------------------------------------------------------------------
  def coz_modalg_category_index
    @coz_modalg_category_index = 0
    if self.note[/\\item_category\[(\d+)]/i] != nil
      @coz_modalg_category_index = $1.to_i
    end
  return @coz_modalg_category_index
  end
end

#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
#  This window displays a list of inventory items for the item screen, etc.
#==============================================================================

class Window_Item < Window_Selectable
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  alias coz_modalg_ssi_refresh refresh
  def refresh(sort_index = 0)
   @sort_index = sort_index
   coz_modalg_ssi_refresh
 end
  #--------------------------------------------------------------------------
  # * Whether or not to include in item list
  #     item : item
  #--------------------------------------------------------------------------
  alias coz_modalg_ssi_include? include?
  def include?(item)
    val = coz_modalg_ssi_include?(item)
    return false if !val
    return case @sort_index
      when 0
        unless COZZIEKUNS::SSI::KYRIAKI_ALL_CATEOGRY_PRIME
          if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
            return false
          else
            return true
          end
        else
          return true
        end
      when 1
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.is_a?(RPG::Item)
        end
      when 2
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.is_a?(RPG::Weapon)
        end
      when 3
        if COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES[item.coz_modalg_category_index][2]
          return false
        else
          return item.is_a?(RPG::Armor)
        end
      when 4..999
        return item.coz_modalg_category_index == @sort_index
      end
    end
  end
 
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
#  This window displays what type of item is being displayed.
#==============================================================================

class Window_ItemCategory < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    @category_string = COZZIEKUNS::SSI::CATEGORY_TEXT
    self.contents.clear
    self.contents.font.color = system_color
    self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @category_string, 0)
    self.contents.font.color = normal_color
    for i in 0...@item_categories.size
      if @sort_index == i
        self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @item_categories[i][1], 2)
      end
    end
  end
end

#==============================================================================
# ** Window_ItemSort
#------------------------------------------------------------------------------
#  This window displays what type of item is being displayed.
#==============================================================================

class Window_ItemSort < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
    @ox = 0
    if COZZIEKUNS::SSI::MAX_NUMBER < COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES.size
      self.contents = Bitmap.new(self.width - 32 + ((COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES.size - COZZIEKUNS::SSI::MAX_NUMBER) * 54), self.height - 32)
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh(sort_index = 0)
    @sort_index = sort_index
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    @item_categories_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    self.contents.clear
    for i in 0...@item_categories.size
      @icon_x = 0 + (i * ((544 - @item_categories_width) / @item_categories.size))
      if @item_categories.size < COZZIEKUNS::SSI::MAX_NUMBER
        draw_item(i)
      else
        draw_items(i)
      end
      if @sort_index == i
        if @item_categories.size < COZZIEKUNS::SSI::MAX_NUMBER
          draw_icon(@item_categories[i][0], @icon_x, 0, true)
        else
          draw_icon(@item_categories[i][0], i * 54, 0, true)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    icons_x = (544 - @item_categories_width) / @item_categories.size
    draw_icon(@item_categories[index][0], index * icons_x, 0, false)
  end
  #--------------------------------------------------------------------------
  # * Draw Items
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_items(index)
    draw_icon(@item_categories[index][0], index * 54, 0, false)
  end
end

#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs the item screen processing.
#==============================================================================

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, 544, 416)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @item_window = Window_Item.new(0, 112, 544, 304)
    @item_window.viewport = @viewport
    @item_window.help_window = @help_window
    @item_window.active = false
    @category_width = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORY_WIDTH
    @category_window = Window_ItemCategory.new(544 - @category_width, 56, @category_width)
    @sort_window = Window_ItemSort.new(0, 56, 544 - @category_width)
    @target_window = Window_MenuStatus.new(0, 0)
    @sort_index = 0
    @item_categories = COZZIEKUNS::SSI::MOD_ALG_ITEM_CATEGORIES
    hide_target_window
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  alias coz_ssi_terminate terminate
  def terminate
    super
    coz_ssi_terminate
    @sort_window.dispose
    @category_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Update Frame
  #--------------------------------------------------------------------------
  alias coz_ssi_update update
  def update
    super
    coz_ssi_update
    @sort_window.update
    @category_window.update
  end
  #--------------------------------------------------------------------------
  # * Update Item Selection
  #--------------------------------------------------------------------------
  def update_item_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      @item = @item_window.item
      if @item != nil
        $game_party.last_item_id = @item.id
      end
      if $game_party.item_can_use?(@item)
        Sound.play_decision
        determine_item
      else
        Sound.play_buzzer
      end
    elsif Input.trigger?(COZZIEKUNS::SSI::RIGHT_BUTTON)
      @sort_index += 1
      @sort_index %= @item_categories.size
      if @sort_index != 0
        if @item_categories.size > COZZIEKUNS::SSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSI::MAX_NUMBER - 1
          @sort_window.ox += 54
        end
      else
        @sort_window.ox = 0
      end
      @category_window.refresh(@sort_index)
      @sort_window.refresh(@sort_index)
      @item_window.refresh(@sort_index)
      @item_window.index = 0
      Sound.play_cursor
    elsif Input.trigger?(COZZIEKUNS::SSI::LEFT_BUTTON)
      @sort_index -= 1
      @sort_index %= @item_categories.size
      if @sort_index + 1 == @item_categories.size
        @sort_window.ox += 54 * (@item_categories.size - COZZIEKUNS::SSI::MAX_NUMBER)
      else
        if @item_categories.size > COZZIEKUNS::SSI::MAX_NUMBER and @sort_index > COZZIEKUNS::SSI::MAX_NUMBER - 2
          @sort_window.ox -= 54
        end
      end
      @category_window.refresh(@sort_index)
      @sort_window.refresh(@sort_index)
      @item_window.refresh(@sort_index)
      @item_window.index = 0
      Sound.play_cursor
    end
  end
end
I've made very minor changes, check the end of the config section to see what I've done. Make sure you know what the buttons are, it's different to your keyboard. For your benefit, by default:
Space/Enter/Z = C
Esc/Num0/X = B
Shift = A
A = X
S = Y
D = Z
Q = L
W = R
C/V/B = -
Title: Re: Simple Sort Inventory
Post by: rofl1337 on June 04, 2011, 02:11:59 PM
Script looks really nice. actually better than the one from KGC that did the same thing, without icons.
I would indeed be interested in a compatibility fix for the MA limited inventory.
Do you think, you would add one later?
sincerly
Title: Re: Simple Sort Inventory
Post by: cozziekuns on August 08, 2011, 01:10:20 AM
Dug through the sloppy code in this script to make an addon for Modern Algebra's Item Instances Base (http://rmrk.net/index.php/topic=43441). Also did some bugfixing, such as adding the ability to remove the special prime categories like All, Items, Weapons, etc. I'll might look into making compatability fixes with things like MA's Limited Inventory, but no promises.
Title: Re: Simple Sort Inventory
Post by: pacdiggity on August 08, 2011, 07:42:39 AM
And removed my added Input functions :mad:
Cool stuff. Loving the avatar by the way. Totally suits you.
Title: Re: Simple Sort Inventory
Post by: rofl1337 on August 29, 2011, 07:37:28 PM
Just want to know for sure. Do you still plan on doing a compatibility fix for MA's Limited Inventory?
The other major sort inventories are also incompatible with LI in addition to having less features and being less likely to be updated.
I would definitely endorse a fix.
sincerely
Title: Re: Simple Sort Inventory
Post by: Heartofshadow on November 06, 2011, 09:45:39 PM
might look into making compatability fixes with things like MA's Limited Inventory, but no promises.
I would thoroughly enjoy a compatibility fix with MA's Limited Inventory. These two scripts working together would be just what I'm looking for.

Hope you end up making one!

-Heart of Shadow-
Title: Re: Simple Sort Inventory
Post by: thomasbradley on March 28, 2012, 03:25:20 AM
Sorry for the necropost, but is there any chance of this getting a compatibility with MA's Evidence Locker? Because I could use it...