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.

[Resolved] Reference To Equiped Items

Status
Not open for further replies.

Mac

Member

Right basically what i'm asking here is a way how to refer to an equip item as if it was an item..e.g.

You have 98 Bronze Swords in your inventory, but you also have one equipped therefore you should have 99 in total but due to having it equipped its no longer in the item menu.

And basically i just wan't to know how i would go about setting it up so that if you went to a shop it would aswell as saying items purchased it would tell you how many people have it equiped.

Thank you, hope that was understandable ^_^
 
Your method is just screwy because of the item types.

Code:
  def draw_item(index)
    item = @data[index]
    # Get items in possession
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
      equipped_number = 0
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
      equipped_number = $game_party.equipped_weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
      equipped_number = $game_party.equipped_armor_number(item.id)
    end
    # If price is less than money in possession, and amount in possession is
    # not 99, then set to normal text color. Otherwise set to disabled color
    if item.price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 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 + 370, y, 88, 32, number.to_s, 2)
    self.contents.draw_text(x + 530, y, 88, 32, equipped_number.to_s, 2)
    self.contents.draw_text(x + 450, y, 88, 32, item.price.to_s, 2)
  end
 
Status
Not open for further replies.

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