WoW:API GetInventoryItemCount: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Move page script moved page API GetInventoryItemCount to API GetInventoryItemCount without leaving a redirect) |
||
(7 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
{{wowapi}} | |||
Determine the quantity of an item in an inventory slot. | |||
count = GetInventoryItemCount("unit", slotId) | |||
== Parameters == | |||
=== Arguments === | |||
:("unit", slotId) | |||
:;unit : String - The [[API TYPE UnitId|UnitId]] of the unit whose inventory is to be queried. | |||
:;slotId : Numeric - The [[API TYPE InventorySlotID|inventory slot]] to be queried, obtained via [[API GetInventorySlotInfo|GetInventorySlotInfo]]. | |||
=== Returns === | |||
:count | |||
:;count : Numeric - Returns 1 on empty slots (Thus, on empty ammo slot, 1 is returned). For containers (Bags, etc.), this returns the number of items stored inside the container (Thus, empty containers return 0). Under all other conditions, this function returns the amount of items in the specified slot. | |||
== Example == | |||
<!-- begin code --> | |||
local ammoSlot = GetInventorySlotInfo("AmmoSlot"); | |||
local ammoCount = GetInventoryItemCount("player", ammoSlot); | |||
if ((ammoCount == 1) and (not GetInventoryItemTexture("player", ammoSlot))) then | |||
ammoCount = 0; | |||
end; | |||
<!-- end code --> | |||
---- | |||
; | |||
---- | ---- | ||
__NOTOC__ | |||
Latest revision as of 04:46, 15 August 2023
← WoW API < GetInventoryItemCount
Determine the quantity of an item in an inventory slot.
count = GetInventoryItemCount("unit", slotId)
Parameters[edit]
Arguments[edit]
- ("unit", slotId)
- unit
- String - The UnitId of the unit whose inventory is to be queried.
- slotId
- Numeric - The inventory slot to be queried, obtained via GetInventorySlotInfo.
Returns[edit]
- count
- count
- Numeric - Returns 1 on empty slots (Thus, on empty ammo slot, 1 is returned). For containers (Bags, etc.), this returns the number of items stored inside the container (Thus, empty containers return 0). Under all other conditions, this function returns the amount of items in the specified slot.
Example[edit]
local ammoSlot = GetInventorySlotInfo("AmmoSlot"); local ammoCount = GetInventoryItemCount("player", ammoSlot); if ((ammoCount == 1) and (not GetInventoryItemTexture("player", ammoSlot))) then ammoCount = 0; end;