BagID

From Warcraft Wiki
Jump to navigation Jump to search

BagIDs are used for accessing bags and their slots. It's recommended to use the container constants to make future WoW patches less likely to break your code.

Values

ID Constants Enum Description
0 BACKPACK_CONTAINER Enum.BagIndex.Backpack The backpack, which has 16-28 item slots.
1 to 4 BACKPACK_CONTAINER:
+1 to +NUM_BAG_SLOTS
Enum.BagIndex.Bag_1 to Bag_4 The equipped bags on the character (from right to left).
5 TheWarWithin-Petopia-Logo.png BACKPACK_CONTAINER+NUM_BAG_SLOTS:
+1 to +NUM_REAGENTBAG_SLOTS
Enum.BagIndex.ReagentBag The equipped reagent bag on the character
6 to 12,
5 to 11 Mists-Logo-Small.png,
5 to 10 WoW Icon Classic.png
BACKPACK_CONTAINER+ITEM_INVENTORY_BANK_BAG_OFFSET:
+1 to +NUM_BANKBAGSLOTS
Enum.BagIndex.BankBag_1 to BankBag_7,
Enum.BagIndex.BankBag_1 to BankBag_6 WoW Icon Classic.png
The bank bags (from left to right).
13 to 17 TheWarWithin-Petopia-Logo.png BACKPACK_CONTAINER+ITEM_INVENTORY_BANK_BAG_OFFSET+NUM_BANKBAGSLOTS:
+1 to +5
Enum.BagIndex.AccountBankTab_1 to AccountBankTab_5 The warbank tab "bags", which have 98 (14*7) item slots each.
-1 BANK_CONTAINER Enum.BagIndex.Bank The bank, which has 28 (7*4) item slots, or 24 (6*4) item slots in WoW Icon Classic.png Classic Era.
-2 WoW Icon Classic.png KEYRING_CONTAINER Enum.BagIndex.Keyring The keyring, which has 32 key item slots.
-3 TheWarWithin-Petopia-Logo.png REAGENTBANK_CONTAINER Enum.BagIndex.Reagentbank The reagent bank, which has 98 (14*7) reagent item slots.
-4 N/A Enum.BagIndex.Bankbag A bank bag container with 7 bag item slots, or 6 bag item slots in WoW Icon Classic.png Classic Era.
-5 TheWarWithin-Petopia-Logo.png N/A Enum.BagIndex.Accountbanktab A warbank tab container with 5 "bag" item slots.

Warning Warning: Mists-Logo-Small.png Mists of Pandaria Classic and WoW Icon Classic.png Classic Era incorrectly use the same enum values for BankBag_1 to BankBag_7 as Retail, so relying on these enums for those game types will result in incorrect behaviour.

Example

Slots start at the topleft of each bag.

Prints all items in your character bags.

for bag = BACKPACK_CONTAINER, NUM_TOTAL_EQUIPPED_BAG_SLOTS do
	for slot = 1, C_Container.GetContainerNumSlots(bag) do
		local itemLink = C_Container.GetContainerItemLink(bag, slot)
		if itemLink then
			print(bag, slot, itemLink)
		end
	end
end
0, 1, "[Red Winter Hat]"
0, 2, "[Red Winter Clothes]"
0, 3, "[Winter Boots]"
0, 9, "[Hearthstone]"
0, 19, "[Snowball]"
0, 20, "[Weighted Jack-o'-Lantern]"
1, 1, "[Celebration Wand - Trogg]"
1, 7, "[Dartol's Rod of Transformation]"

See also

Patch changes