WoW:BagId: Difference between revisions

6 bytes removed ,  15 August 2023
m
Move page script moved page BagId to WoW:BagId without leaving a redirect
No edit summary
m (Move page script moved page BagId to WoW:BagId without leaving a redirect)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{wowapitype}}<br>
{{wowapitype}}
 
While dealing with container and inventory items, many developers use a bag/slot couple and set bag to -1 for the case of an inventory item. But a problem occurs when the bank is opened (after BANKFRAME_OPENED event being fired) because the 28 slots of the bank count as actual container slots with -1 as bagID. In the same idea, items in the bank bags can be accessed via container item functions (like [[API GetContainerItemLink|GetContainerItemLink(bagID, slotID)]], [[API PickupContainerItem|PickupContainerItem(bagID, slotID)]]) with 5 as bagID for the first bank bag, 6 for the second ... until 11 for the seventh.
While dealing with container and inventory items, many developers use a bag/slot couple and set bag to -1 for the case of an inventory item. But a problem occurs when the bank is opened (after BANKFRAME_OPENED event being fired) because the 28 slots of the bank count as actual container slots with -1 as bagID. In the same idea, items in the bank bags can be accessed via container item functions (like [[API GetContainerItemLink|GetContainerItemLink(bagID, slotID)]], [[API PickupContainerItem|PickupContainerItem(bagID, slotID)]]) with 5 as bagID for the first bank bag, 6 for the second ... until 11 for the seventh.


Line 27: Line 26:
* NUM_BAG_SLOTS+1 to NUM_BAG_SLOTS+NUM_BANKBAGSLOTS are your bank bags
* NUM_BAG_SLOTS+1 to NUM_BAG_SLOTS+NUM_BANKBAGSLOTS are your bank bags


This follows the way [[FrameXML]] works. Future changes to APIs are less likely to make your addon break if you follow it. Many of these globals are defined in FrameXML\Constants.lua, if you're curious.
This follows the way [[FrameXML]] works. Future changes to APIs are less likely to make your addon break if you follow it. Many of these globals are defined in FrameXML\Constants.lua, if you're curious.
Anonymous user