WoW:API ContainerIDToInventoryID: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
m (Move page script moved page API ContainerIDToInventoryID to API ContainerIDToInventoryID without leaving a redirect)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{wowapi}}
{{wowapi}} __NOTOC__
<center>'''ContainerIDToInventoryID''' ''-Documentation by [[user:Luke1410|Luke1410]]-''</center>
 
----
inventoryId = ContainerIDToInventoryID(bagID)
;''Arguments''
 
== Arguments ==
 
:;:(bagID)
:;:(bagID)
:::;bagID : [[API TYPE bagID|bagID]] - number of the bag (0-11) to get the inventoryID for.


Note: After TBC Closed Beta patch v2.0.3.6299 (8th Jan 2007), inputs outside the range of 0-11 (0-4 for bags, and 5-11 for bank) now throw "invalid container ID" errors.
:::;bagID : [[API TYPE bagID|bagID]] - number of the bag (1 -- NUM_BAG_SLOTS+NUM_BANKBAGSLOTS) to get the inventoryID for.


----
== Returns ==
;''Returns''


:;inventoryID
:;inventoryID
:: inventoryID - the bag's inventory ID used in functions like [[API PutItemInBag|PutItemInBag(inventoryId)]] and [[API GetInventoryItemLink|GetInventoryItemLink("player",inventoryId)]]
:: inventoryID - the bag's inventory ID used in functions like [[API PutItemInBag|PutItemInBag(inventoryId)]] and [[API GetInventoryItemLink|GetInventoryItemLink("player",inventoryId)]]
----
 
;''Examples''
== Example ==


  local invID = ContainerIDToInventoryID(1)   
  local invID = ContainerIDToInventoryID(1)   
  DEFAULT_CHAT_FRAME:AddMessage("Bag slot 1 is inventory slot "..invID)
local bagLink = GetInventoryItemLink("player",invID)
  DEFAULT_CHAT_FRAME:AddMessage("Bag slot 1 is inventory slot "..invID..", a "..bagLink)


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


  Bag slot 1 is inventory slot 20
  Bag slot 1 is inventory slot 20, a [Imbued Netherweave Bag]


----
== Notes ==
;''Notes''


:The return of container IDs -2 (key ring), -1 (bank) and 0 (backpack) aren't actual Inventory slots usable by most Inventory functions.
:Querying for items outside the range 1 -- (NUM_BAG_SLOTS+NUM_BANKBAGSLOTS) throws an error.
:The player bags begin at container 1 and inventory 20.
:The player bags begin at container 1 -- currently inventory slot 20.
:The bank bags begin at container 5 and inventory 68.
:The bank bags begin at container 5 (1+NUM_BAG_SLOTS) -- currently inventory slot 68.

Latest revision as of 04:45, 15 August 2023

WoW API < ContainerIDToInventoryID

inventoryId = ContainerIDToInventoryID(bagID)

Arguments[edit]

(bagID)
bagID
bagID - number of the bag (1 -- NUM_BAG_SLOTS+NUM_BANKBAGSLOTS) to get the inventoryID for.

Returns[edit]

inventoryID
inventoryID - the bag's inventory ID used in functions like PutItemInBag(inventoryId) and GetInventoryItemLink("player",inventoryId)

Example[edit]

local invID = ContainerIDToInventoryID(1)  
local bagLink = GetInventoryItemLink("player",invID)
DEFAULT_CHAT_FRAME:AddMessage("Bag slot 1 is inventory slot "..invID..", a "..bagLink)

Result[edit]

Bag slot 1 is inventory slot 20, a [Imbued Netherweave Bag]

Notes[edit]

Querying for items outside the range 1 -- (NUM_BAG_SLOTS+NUM_BANKBAGSLOTS) throws an error.
The player bags begin at container 1 -- currently inventory slot 20.
The bank bags begin at container 5 (1+NUM_BAG_SLOTS) -- currently inventory slot 68.