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.

Inventory Script

I think this could be edited:

Code:
#==============================================================================
# Icon Inventory System - Scripted By Mac
#------------------------------------------------------------------------------
# This window displays the Icons and the amount of the item you have.
#==============================================================================

class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
  super(0, 63, 640, 300)
  @column_max = 10
  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
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
  return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
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
    @data.push($data_items[i])
   end
  end
  # Also add weapons and items if outside of battle
  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
  # 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
#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#--------------------------------------------------------------------------
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 % 10 * (32 + 32)
  y = index / 10 * 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, y + 9, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------

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

What I'm looking for is I want the inventory scaled down so that it goes from this:
http://i125.photobucket.com/albums/p76/rih29/inventory.png[/img]
To this:
http://i125.photobucket.com/albums/p76/rih29/INVENTORY2.png[/img]

The black part being transparent, so you can see the map behind the window. I would assume this would just involve resizing the columns and ordering and windows and then making the black part transparent.

Could someone please do this for me? :)
 
Code:
#==============================================================================
# Icon Inventory System - Scripted By Mac
#------------------------------------------------------------------------------
# This window displays the Icons and the amount of the item you have.
# Modified per MrRobert - Brew 11MAR08
#==============================================================================

class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
  super(384, 63, 256, 192) #tb
  @column_max = 4  #tb
  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
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
  return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
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
    @data.push($data_items[i])
   end
  end
  # Also add weapons and items if outside of battle
  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
  # 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
#--------------------------------------------------------------------------
# * Draw Item
#  index : item number
#--------------------------------------------------------------------------
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 % 4 * (32 + 32)
  y = index / 4 * 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, y + 9, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------

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

class Scene_Item
  alias orig_main main
  def main
    @map_bg = Spriteset_Map.new
    orig_main
    @map_bg.dispose
  end
end

I didn't test it in battle yet...
 
Thanks, Brew! :) Again you save the day.

Do you think it would be possible to edit the default Skills, Equipment, and Stats menu in the same fashion? If you could do that when you have the time, I'd be more than pleased. :)

And no need to test the item menu in battle, I'm using NeoABS.
 
I tested it in battle. It works fine.

Skills: we could do, since it's just a list.  (I assume you mean just make it smaller, and on the right side)
Equip: You could shrink the bottom window that lists the equipment, wouldn't gain you much space?
Status: If you make the window smaller, you'll have to rearrange the information. If you want to draw up a 'mock-up', I can make it match.

Be Well
 
Skills: we could do, since it's just a list.  (I assume you mean just make it smaller, and on the right side)
Yes, precisely.
Equip: You could shrink the bottom window that lists the equipment, wouldn't gain you much space?
I've done that but I'm not sure how to make the black change to transparent.
Status: If you make the window smaller, you'll have to rearrange the information. If you want to draw up a 'mock-up', I can make it match.
Here's what I want, since my game only has one character, it's smaller.
http://i125.photobucket.com/albums/p76/rih29/STATS.png[/img]
It doesn't have to be exactly like that, as long as it's compact and on the right of the screen. I want there to be an extra accessory slot but I don't know how to do it without going through those tedious over-loaded multi-equipment scripts. If you can direct me to something that simply adds one extra accessory slot, and make the equip/stat menu compatible with it, I'd love you forever, haha.

Be Well
 
...but I'm not sure how to make the black change to transparent.

You don't. The map is gone at this point.
However, since all of the 'state' data for the current map is stored, so you can come
back to it in the same state, you can quickly capture an image of what it looks like.

See the last part of the script...

Code:
class Scene_Item
  alias orig_main main
  def main
    @map_bg = Spriteset_Map.new
    orig_main
    @map_bg.dispose
  end
end

This just says, for the class 'Scene_Item', alias the original 'main' code as 'orig_main',
and run this version of main instead.
Then I define the new 'main' function to create a sprite of the map we were just on,
run the original 'main' method
then dispose of the sprite when it's all done.

You can do the same thing with the Scene_Equip & Scene_Status classes.

I'll take a stab at the status window later tonight.

Be Well
 

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