Main Menu
  • Welcome to The RPG Maker Resource Kit.

Simple Item Division - In the Works

Started by Tsunokiette, September 12, 2006, 03:22:13 AM

0 Members and 1 Guest are viewing this topic.

Tsunokiette

The first window is done, I just have two more to program then the scene, and the new Scene_Item shall be complete.

class Item_List
attr_accessor :consumable
attr_accessor :equipment
attr_accessor :key
def initialize
@consumable = []
@equipment = []
@key = []
end
def create
for i in 1...$data_items.size
item = $data_items[i]
case item
when RPG::Item
temp = item.name.split(/ /)
if temp[temp.size - 1] != "[K]"
@consumable.push(item)
elsif temp[temp.size - 1] == "[K]"
@key.push(item)
end
when RPG::Weapon
@equipment.push(item)
when RPG::Armor
@equipment.push(item)
end
end
end
end

class Window_Base_Enhanced < Window_Selectable
def w
self.width
end
def h
self.height
end
def cw
self.contents.width
end
def ch
self.contents.height
end
def tw(text)
contents.text_size(text).width
end
def th(text)
contents.text_size(text).height
end
end

class Window_Item < Window_Base_Enhanced
attr_reader :index
attr_reader :page
def initialize
list = Item_List.new
list.create
@consumable = list.consumable
@equipment = list.equipment
@key = list.key
@page = 0
@index = 0
super(1, 98, 638, 381)
self.contents = Bitmap.new(w - 32, h - 32)
refresh
end
def refresh
self.contents.clear
case @page
when 0
list = @consumable
for i in 0...(list.size)
draw_item(list[i],$game_party.item_number(list[i].id)
end
when 1
list = @equipment
for i in 0...(list.size)
case list[i]
when RPG::Weapon
draw_item(list[i],$game_party.weapon_number(list[i].id)
when RPG::Armor
draw_item(list[i],$game_party.armor_number(list[i].id)
end
end
when 2
list = @key
for i in 0...(list.size)
draw_item(list[i],$game_party.item_number(list[i].id)
end
end
end
def draw_item(item,quantity)
item_w = cw / 3
item_h = ch / th(item.name)
item_x = item_w * (@index % 3)
item_y = item_h * (@index / 3)
if quantity < 10
q_w = tw(" #{quantity}")
else
q_w = tw("#{quantity}")
end
item_name_w = item_w - q_w - 8
if quantity = 0
self.contents.font.color = knockout_color
else
self.contents.font.color = system_color
end
self.contents.draw_text(item_x,item_y,q_w,item_h,"#{quantity}")
self.contents.font.color = normal_color
temp = item_x + q_w + (4 * (@index % 3)) + (4 * ((@index %3) + 1))
self.contents.draw_text(temp,item_y,item_name_w,item_h,item.name)
end
def page=(value)
@page = value
refresh
end
end
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Arrow

I don't mean to ask a stupid question, but I am...What does it do?

Tsunokiette

#2
Nothing at the moment, but when I'm done it'll automaticly organize your items into the categories -

Consumable
Equipment
Key

(Key being Key Items, ie. those that stay with you forever)

To make an item a key item, in its name you just put a space, then "[K]"

For Example, to make key Card change to a key item change the name from (ignore quotes) -

"Key Card"

to

"Key Card [K]"

EDIT :@Zeriab - If you've read this, you would notice three errors I've made so far -

1 ) I didn't specify @item_size or @rows / @columns

2 ) Coordinates for items are wrong

3 ) Need to rewrite tw and th methods

Also, this isn't an error as much as just not thinking, I need to rewrite what it draws for each item, ie. I forgot to draw the icons, etc.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They're bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I'm the only one, I'm the only one."

Zeriab

I'll just wait looking through this until you say you have finished it. Alright?