WoW:API GetContainerItemInfo: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(Confirmed that "readable" marks items that are read)
m (Move page script moved page API GetContainerItemInfo to API GetContainerItemInfo without leaving a redirect)
 
(14 intermediate revisions by 14 users not shown)
Line 1: Line 1:
<center>'''GetContainerItemInfo''' ''-Documentation by Arvenis-''</center>
{{wowapi}} __NOTOC__
----
;''Arguments''
:;:(bag,slot)
:::;bag : number - number of the bag the item is in, 1 is your backpack, 2-5 are the four additional bags
:::;slot : number - slot number of the bag item you want the info for.


----
texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo(bagID, slot);
;''Returns''


:;texture, itemCount, locked, quality, readable : texture - the texture for the item in the specified bag slot
== Parameters ==
:;;;: itemCount - the number of items in the specified bag slot
=== Arguments ===
:;;;: locked - true if locked; that is, a stack that cannot be split
:;;;: quality - the numeric quality of the item
:;;;: readable - true if the item can be "read" (as in a book)
----
;''Examples''


local texture, itemCount = GetContainerItemInfo(1,2);
:;[[bagID]] : Number - number of the bag the item is in, e.g. 0 for your backpack
:;slot : Number - slot number of the bag item you want the info for.


: If you are only interested in one of these values you can use the _ character to ignore the texture or the itemCount.
=== Returns ===
:;texture : String - the texture for the item in the specified bag slot
:;itemCount : Number - the number of items in the specified bag slot
:;locked : [[Boolean]] - 1 if the item is locked by the server, nil otherwise.
:;quality : Number - the numeric quality of the item
:;readable : [[Boolean]] - 1 if the item can be "read" (as in a book)
:;lootable : [[Boolean]] - 1 if the item is a temporary container containing items that can be looted; otherwise nil.
:;[[itemLink]] : a hyperlink for the item.


local _,itemCount = GetContainerItemInfo(1,2);
== Example ==
local texture,_ = GetContainerItemInfo(1,2);


''See also:'' [[API_GetInventorySlotInfo|GetInventorySlotInfo]] to get the same information from a player's inventory (or equipped items).
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(1,2);
DEFAULT_CHAT_FRAME:AddMessage(itemCount .. " stacked items in 2nd slot of bag 1.");


----
=== Result ===
;''Result''


: The texture variable will contain the item's texture and the itemCount variable will contain the number of that item in the slot.
: The texture variable will contain the item's texture and the itemCount variable will contain the number of that item in the slot.


: quality result does not appear to directly correspond with the color used to display the item name, it only appears to be defined for equipment (as opposed to trade items).
: The quality return value will either be -1 or a standard [[API TYPE_Quality|quality]] value from 0 to 6. A value of -1 seems to indicate that the item requires special handling: It's stackable, it's unique or it's a quest item.


: readable simply marks if there is text related to the item.  When it's true, the default UI changes the cursor to the "Read" cursor (the magnifying glass) when the mouse is over the item button.
: The readable return value simply indicates if there is text related to the item.  If it's true, the default UI will change the cursor to the "Read" cursor (the magnifying glass) when the mouse is over the item button.


----
: An item in a character's inventory can become "locked" for a number of reasons.  It might be locked because it is attached to the cursor, or because it has been split and the new stack is attached to the cursor, or because is in the "create auction" item slot, or because it is in a trade slot.  In all of these cases, the item is considered to be "locked".  Also, typically, the item's icon is shown in grayscale.  The item will become unlocked when the action that locked the icon is complete.  When the item's move is finished (and the server accepts the move), the item will become unlocked.  When the server reports that the auction has been created, the item will become unlocked (although it will also disappear).  During the period that the item is locked, some methods that affect the item (such as [[API PickupContainerItem|PickupContainerItem]]) silently fail.
{{Template:WoW API}}
 
[[Category:API Inventory Functions|GetContainerItemInfo]]
== Example ==
 
/script DEFAULT_CHAT_FRAME:AddMessage( (select(2, GetContainerItemInfo(1,1))) )
 
=== Result ===
 
: This macro will print out the item count for the item located in slot 1 of bag 1. Different indices, instead of 2, can be used to slice out a specific return value.

Latest revision as of 04:45, 15 August 2023

WoW API < GetContainerItemInfo

texture, itemCount, locked, quality, readable, lootable, itemLink = GetContainerItemInfo(bagID, slot);

Parameters[edit]

Arguments[edit]

bagID
Number - number of the bag the item is in, e.g. 0 for your backpack
slot
Number - slot number of the bag item you want the info for.

Returns[edit]

texture
String - the texture for the item in the specified bag slot
itemCount
Number - the number of items in the specified bag slot
locked
Boolean - 1 if the item is locked by the server, nil otherwise.
quality
Number - the numeric quality of the item
readable
Boolean - 1 if the item can be "read" (as in a book)
lootable
Boolean - 1 if the item is a temporary container containing items that can be looted; otherwise nil.
itemLink
a hyperlink for the item.

Example[edit]

local texture, itemCount, locked, quality, readable = GetContainerItemInfo(1,2);
DEFAULT_CHAT_FRAME:AddMessage(itemCount .. " stacked items in 2nd slot of bag 1.");

Result[edit]

The texture variable will contain the item's texture and the itemCount variable will contain the number of that item in the slot.
The quality return value will either be -1 or a standard quality value from 0 to 6. A value of -1 seems to indicate that the item requires special handling: It's stackable, it's unique or it's a quest item.
The readable return value simply indicates if there is text related to the item. If it's true, the default UI will change the cursor to the "Read" cursor (the magnifying glass) when the mouse is over the item button.
An item in a character's inventory can become "locked" for a number of reasons. It might be locked because it is attached to the cursor, or because it has been split and the new stack is attached to the cursor, or because is in the "create auction" item slot, or because it is in a trade slot. In all of these cases, the item is considered to be "locked". Also, typically, the item's icon is shown in grayscale. The item will become unlocked when the action that locked the icon is complete. When the item's move is finished (and the server accepts the move), the item will become unlocked. When the server reports that the auction has been created, the item will become unlocked (although it will also disappear). During the period that the item is locked, some methods that affect the item (such as PickupContainerItem) silently fail.

Example[edit]

/script DEFAULT_CHAT_FRAME:AddMessage( (select(2, GetContainerItemInfo(1,1))) )

Result[edit]

This macro will print out the item count for the item located in slot 1 of bag 1. Different indices, instead of 2, can be used to slice out a specific return value.