GetItemCount

From Warcraft Wiki
Jump to navigation Jump to search

Returns the number (or available charges) of an item in the inventory.

count = GetItemCount(itemInfo [, includeBank, includeUses, includeReagentBank])

Arguments

itemInfo
number|string - Item ID, Link or Name
includeBank
boolean? - If true, includes the bank
includeUses
boolean? - If true, includes each charge of an item similar to GetActionCount()
includeReagentBank
boolean? - If true, includes the reagent bank

Returns

count
number - The number of items in your possession, or charges if includeUses is true and the item has charges.

Example

local count = GetItemCount(29434)
print("Badge of Justice:", count)

local count = GetItemCount(33312, nil, true) 
print("Mana Saphire Charges:", count)

local clothInBags = GetItemCount("Netherweave Cloth")
local clothInTotal = GetItemCount("Netherweave Cloth", true)
print("Netherweave Cloth:", clothInBags, "(bags)", (clothInTotal - clothInBags), "(bank)")

Patch changes

Legion Patch 7.2.0 (2017-03-28): Added includeReagentBank optional argument.[1]
Bc icon.gif Patch 2.3.0 (2007-11-13): Added includeUses optional argument.[2]
Bc icon.gif Patch 2.0.1 (2006-12-05): Added.[3]

References

 
  1. ^ 2017-03-28, MerchantFrame.lua, version 7.2.0.23835, near line 578, archived at Townlong-Yak
  2. ^ Iriel 2007-08-27. Upcoming 2.3 Changes - Concise List. BlueTracker. Archived from the original
  3. ^ Blizzard Entertainment slouken 2006-10-11. Re: 2.0.0 Changes - Concise List. Archived from the original