This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
:note: Well, you can sort:
Alphabetically
By cost
By Size(read on)
By weight(read on)
Show only items
Show only weapons
Show only armors
Show only shields
Show only helmets
Show only Accessories
Show only keyitems(read on)
Interested? Call 1800-JITEM NOW
(j/k)
Here's the script and instructions for installing. It will take A LONG time to set up, ESPECIALLY if you have alot of items, weapons and armors...
So sit back and listen :icon_jook:
Put THESE scripts in new spots above main:
Item METHODS
Code:
class Game_Item
def size(item)
case item
when RPG::Item
for i in 0...SIZES.size
if item.element_set.include?(SIZES[i][2])
return SIZES[i]
end
end
when RPG::Weapon
for i in 0...SIZES.size
if item.element_set.include?(SIZES[i][2])
return SIZES[i]
end
end
when RPG::Armor
for i in 0...SIZES.size
if item.guard_element_set.include?(SIZES[i][2])
return SIZES[i]
end
end
end
return SIZES[DEFAULT[0]]
end
def weight(item)
case item
when RPG::Item
for i in 0...WEIGHTS.size
if item.element_set.include?(WEIGHTS[i][2])
return WEIGHTS[i]
end
end
when RPG::Weapon
for i in 0...WEIGHTS.size
if item.element_set.include?(WEIGHTS[i][2])
return WEIGHTS[i]
end
end
when RPG::Armor
for i in 0...WEIGHTS.size
if item.guard_element_set.include?(WEIGHTS[i][2])
return WEIGHTS[i]
end
end
end
return WEIGHTS[DEFAULT[1]]
end
def keyitem(item)
case item
when RPG::Item
return item.element_set.include?(KEY_ITEM)
when RPG::Weapon
return item.element_set.include?(KEY_ITEM)
when RPG::Armor
return item.guard_element_set.include?(KEY_ITEM)
end
end
end
Constans and Instructions
Code:
#What is this?
#KEY_ITEM
#Any item given this attribute is automatically considered a "Key item" and
#it will be not be shown by selecting the "Key Items" choice, in addition to it's type choice.
#SIZES
#This hash contains a few predefined sizes, to add a size of your own, copy the last one,
#add 1 to the second number(24) and change the name/size(first number) as you want.
#You'll then have to increment all "WEIGHTS" numbers as well.
#the word-->What will be displayed in the "size" box when the item is selected.
#the first number-->How big the item is, 1 is smallest, your imagination chooses the largest...
#the second number-->What attribute will be used for choosing the size of the item.
#This goes for Weights as well, with minor (and obvious) modifications.
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 128, 640, 352)
@column_max = 2
refresh
self.index = 0
# 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def reset
@data=[]
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
return
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
if @datt != nil
@data=@datt
else
@data=[]
# アイテムを追加
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
# 戦闘中以外なら武器と防具も追加
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
end
# 項目数が 0 でなければビットマップを作成し、全項目を描画
case $sort
when 0#alphabetical
case $method
when 0
@data.sort!{|a,b|a.name<=>b.name}
when 1
@data.sort!{|a,b|b.name<=>a.name}
end
when 1#costwise
case $method
when 0
@data.sort!{|a,b|a.price<=>b.price}
when 1
@data.sort!{|a,b|b.price<=>a.price}
end
when 2#sizewise
case $method
when 0
@data.sort!{|a,b|$game_item.size(a)[1]<=>$game_item.size(b)[1]}
when 1
@data.sort!{|a,b|$game_item.size(b)[1]<=>$game_item.size(a)[1]}
end
when 3#weightwise
case $method
when 0
@data.sort!{|a,b|$game_item.weight(a)[1]<=>$game_item.weight(b)[1]}
when 1
@data.sort!{|a,b|$game_item.weight(b)[1]<=>$game_item.weight(a)[1]}
end
when 4#Items ONLY
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Item)}
@data=@data2
@datt=@data
when 5#Weapons ONLY
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Weapon)}
@data=@data2
@datt=@data
when 6#Armor only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==2}
@data=@data2
end
@datt=@data
when 7#shield only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==0}
@data=@data2
end
@datt=@data
when 8#helmet only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==1}
@data=@data2
end
@datt=@data
when 9#acc only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==3}
@data=@data2
end
@datt=@data
when 10#Keyitems
reset
@data2=[]
@data.each{|a|@data2.push(a) if $game_item.keyitem(a)}
@data=@data2
@datt=@data
when 11
reset
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $defaultfonttype # "Items" window font
self.contents.font.size = $defaultfontsize
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
Well, done... NOT :icon_fU:
If you want a "lighter" version that doesn't take as long to setup, scroll down a bit. You still have to start the game with the call script, but the only dtabase work needed is for keyitems.
UPDATE:
Fixed the glitch with the cursor staying in position even if there isn't an item there after sorting, just copy Scene_Item again. Some unneccesary methods in Item METHODS were removed as well.