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.

Menu addition - view items

Script Title: Item/Weapon/Armor viewing thingy
RMXP or RMVX: XP
Detailed Description:
I tried searching for something like this, but didn't come across anything. Anyhoo, I'm looking for an addition to the item and equip scripts, based sort of on the Shadow Hearts menus. In those games, when you have an item or piece of equipment highlighted, instead of selecting it you can press another button and a big image and description of that thing will come up. So basically, what I'd like is for when an item in the Item or Equip menus is highlighted, if you press a button that is not the 'select' button, a picture is shown in the center of the screen. Probably an image from the Pictures folder that has the same name as the icon?
Other Scripts I am using (in order):
The only script I'm using that would probably affect this is a custom Item script. I do have a custom menu, too, but I don't THINK that would be used.

Code:
#==============================================================================

#  Window_Item

#------------------------------------------------------------------------------

#  Allows a player to select an item in the item and battle scenes.

#==============================================================================

 

class Window_Item < Window_Selectable

attr_accessor :use

attr_accessor :show_keyitems

#--------------------------------------------------------------------------

#  Initialize the item window

#--------------------------------------------------------------------------

def initialize

 super(0, 128, 640, 352)

 @use = true

 @column_max = 2

 @show_keyitems = false

 refresh

 self.index = 0

 # If in a battle, move the window to the center of the screen and make

 # it translucent

 if $game_temp.in_battle

   self.y = 64

   self.height = 256

   self.back_opacity = 160

 end

end

#--------------------------------------------------------------------------

#  Get selected item

#--------------------------------------------------------------------------

def item

 return @data[self.index]

end

#--------------------------------------------------------------------------

#  Selects the last item in the list

#--------------------------------------------------------------------------

def select_last

 self.index = [@data.size - 1, 0].max

end

#--------------------------------------------------------------------------

#  Refresh the contents of the window

#--------------------------------------------------------------------------

def refresh

 if self.contents != nil

   self.contents.dispose

   self.contents = nil

 end

 @data = []

 # Add items

 for i in 1...$data_items.size

   if $game_party.item_number(i) > 0

     # Only show key items when in key item mode

     if $data_items[i].element_set.include?(KEY_ITEM_ATTRIBUTE)

       if @show_keyitems

         # If key items are split, this will give a number of

         # seperate entries equal to the quantity of the item

         # possessed

         if SPLIT_KEYITEMS

           for j in 0...$game_party.item_number(i)

             @data.push($data_items[i])

           end

         else

           # Otherwise, add it once

           @data.push($data_items[i])

         end

       end

     elsif not @show_keyitems

       @data.push($data_items[i])

     end

   end

 end

 # Unless in a battle, add weapons and armor

 unless $game_temp.in_battle

   for i in 1...$data_weapons.size

     if $game_party.weapon_number(i) > 0

       # Only show key items when in key item mode

       if $data_weapons[i].element_set.include?(KEY_ITEM_ATTRIBUTE)

         if @show_keyitems

           # If key items are split, this will give a number of

           # seperate entries equal to the quantity of the item

           # possessed

           if SPLIT_KEYITEMS

             for j in 0...$game_party.weapon_number(i)

               @data.push($data_weapons[i])

             end

           else

             # Otherwise, add it once

             @data.push($data_weapons[i])

           end

         end

       elsif not @show_keyitems

         @data.push($data_weapons[i])

       end

     end

   end

   for i in 1...$data_armors.size

     if $game_party.armor_number(i) > 0

       # Only show key items when in key item mode

       if $data_armors[i].guard_element_set.include?(KEY_ITEM_ATTRIBUTE)

         if @show_keyitems

           # If key items are split, this will give a number of

           # seperate entries equal to the quantity of the item

           # possessed

           if SPLIT_KEYITEMS

             for j in 0...$game_party.armor_number(i)

               @data.push($data_armors[i])

             end

           else

             # Otherwise, add it once

             @data.push($data_armors[i])

           end

         end

       elsif not @show_keyitems

         @data.push($data_armors[i])

       end

     end

   end

 end

 # If there are items to show, draw them on the screen

 @item_max = @data.size

 if @item_max > 0

   self.contents = Bitmap.new(width - 32, row_max * 32)

   self.contents.font.name = $fontface

   self.contents.font.size = $fontsize

   for i in 0...@item_max

     draw_item(i)

   end

 end

end

#--------------------------------------------------------------------------

#  Draw an item

#     index : The index (in @data) of the item to draw

#--------------------------------------------------------------------------

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 @show_keyitems

   self.contents.font.color = normal_color

 elsif @use

   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

 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)

 

 # Disgusting bit of logic that determines whether or not the quantity

 # of the item is shown (for key item display)

 unless @show_keyitems and

 ((number == 1 and not SHOW_KEYITEM_QUANTITY_WHEN_SINGULAR) or

 SPLIT_KEYITEMS)

   self.contents.draw_text(x + 240, y, 16, 32, ":", 1)

   self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)

 end

end

#--------------------------------------------------------------------------

#  Update help window text

#--------------------------------------------------------------------------

def update_help

 @help_window.set_text(self.item == nil ? "" : self.item.description)

end

end

Here's an example. I called up the pictures using another event, of course. Um, those aren't actual items I use...
carrot1.png

carrot2.png

Sword1.png

Sword2.png
 
Well, at heart I'm not much of a scripter, but logically speaking, I can see how this could work.
I'll have a go, but don't be dissappointed if I can't manage it.

edit: And sadly your custom item window requires something that I don't have it seems.
 

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