Display item quantity in battle scene

Hello! I'm trying to show one item (ammo) quantity in the battle scene. I only succeeded to understand that It's impossible for me to do, because i can't code at all... I would be glad if someone could help!


Layout is number which is the quantity of the item (id=100) and then 24x24 icon from IconSet.png (30). In upper right window place. You can see it in the picture added. It should be visible during all the battle or better only when player party hud is showing (basically when player can choose what to do). I use hotkey system to choose battle skills without surfing through battle commands. All of the skills have requirement of the same ammo. Every time when player uses skill, it reduces quantity of that item (I use Yanfly Engine Ace - Skill Cost Manager v1.03). That is why I want to show ammo quantity on battle screen that will refresh every time player uses skill. Because in that case player can see how many ammo is left and decide which skill (some of skills needs more ammo, some less) to use without going through the battle command to the item list every turn to check the ammo quantity.


Thank You for your patience of my super engrish 😉


Untitled.png
We would need a copy or link to the script that you are using to display the keys/items so we can add on to or edit it.
So it's on the top left of the screen all through out the battle?


There you go:


#==============================================================================
# ■ Meow Face Battle Ammo Window
#------------------------------------------------------------------------------
# Add Ammo to Battle Scene
#==============================================================================
# How to Use:
# [1] Paste this below Material and above Main
#==============================================================================
module MeowSAMMO #DO NOT REMOVE!!
#==============================================================================
# Settings Area
#==============================================================================
ICON = 30 #Enter Icon ID here
ITEM = 100 #Enter Item ID here
#==============================================================================
# End of Settings Area
# Edit anything past this line at your own risk!
#==============================================================================
end
class Window_Ammo < Window_Base
def initialize
super(0, 0, window_width, fitting_height(1))
@last_qty = 0
self.opacity = 0
refresh
end
def window_width
return Graphics.width
end
def refresh
contents.clear
quantity = $game_party.item_number($data_items[MeowSAMMO::ITEM])
icon = MeowSAMMO::ICON
draw_icon(icon, contents.width-24, 0)
draw_text(0, 0, contents.width-24, line_height, quantity, 2)
@last_qty = quantity
end
def need_refresh?
@last_qty != $game_party.item_number($data_items[MeowSAMMO::ITEM])
end
end
class Scene_Battle < Scene_Base
alias meow_face_baw_sb create_all_windows
def create_all_windows
meow_face_baw_sb
create_ammo_window
end
def create_ammo_window
@ammo_window = Window_Ammo.new
end
alias meow_ammo_update update
def update
@ammo_window.refresh if @ammo_window.need_refresh?
meow_ammo_update
end
end


let me know if you run into any problem
It works! Thank You! Im gonna test and write if everything is ok. I'm getting one error but I think it's not related with this script.
It works! Thank You! Im gonna test and write if everything is ok. I'm getting one error but I think it's not related with this script.

You are welcome!


This script is either using new or alias method, so it's unlikely to cause conflicts. Simply place it below your battle scripts will do.
The script works perfect and gives no errors at all, thank You!


I know I requested only one item quantity display, but... After finished setting all battle skills I see that I need to show 5 item counts with 5 different icons on battle. Is it... too much to ask You to update given script, MeowFace? I tried by myself but only getting script duplication error (SystemStackError)... Please help!
How would you go about adding multiple ammo types?
How would you go about adding multiple ammo types?
You're necro posting but before this gets closed...
Ruby:
#==============================================================================
# ■ Meow Face Battle Ammo Window
#------------------------------------------------------------------------------
# Add Ammo to Battle Scene
#==============================================================================
# How to Use:
# [1] Paste this below Material and above Main
#==============================================================================
module MeowSAMMO #DO NOT REMOVE!!
#==============================================================================
# Settings Area
#==============================================================================
  # numbers shown here are displayed in reverse order on the screen
  ICON = [30, 31, 32, 33, 34, 35] # Enter Icon ID(s) here
  ITEM = [10, 11, 12, 13, 14, 15] # Enter Item ID(s) here
  SEPARATION = 64 # space used to seperate icons, includes number shown
  LINE_Y = 0 # used to have the display lower on the screen
#==============================================================================
# End of Settings Area
# Edit anything past this line at your own risk!
#==============================================================================
end
class Window_Ammo < Window_Base
  def initialize
    super(0, MeowSAMMO::LINE_Y, window_width, fitting_height(1))
    @last_qty = []
    self.opacity = 0
    refresh
  end
  def window_width
    return Graphics.width
  end
  def refresh
    contents.clear
    rpt = MeowSAMMO::ICON.size
    x = 0
    rpt.times do |i|
      quantity = $game_party.item_number($data_items[MeowSAMMO::ITEM[i]])
      icon = MeowSAMMO::ICON[i]
      draw_icon(icon, contents.width - 24 - x, 0)
      draw_text(0, 0, contents.width - 24 - x, line_height, quantity, 2)
      @last_qty[i] = quantity
      x += MeowSAMMO::SEPARATION
    end
  end
  def need_refresh?
    rpt = MeowSAMMO::ICON.size
    rpt.times do |i|
      return true if @last_qty[i] != $game_party.item_number($data_items[MeowSAMMO::ITEM[i]])
    end
  end
end
class Scene_Battle < Scene_Base
  alias meow_face_baw_sb create_all_windows
  def create_all_windows
    meow_face_baw_sb
    create_ammo_window
  end
  def create_ammo_window
    @ammo_window = Window_Ammo.new
  end
  alias meow_ammo_update update
  def update
    @ammo_window.refresh if @ammo_window.need_refresh?
    meow_ammo_update
  end
end

Original thread: https://forums.rpgmakerweb.com/threads/display-item-quantity-in-battle-scene.55822/