IsBagOpen()

From Warcraft Wiki
Jump to navigation Jump to search
This function is implemented in FrameXML/ContainerFrame.lua.
container = IsBagOpen(BagID)
CloseBag(id)

Arguments

BagID
Number - Unique identifier for each bag

Returns

container
Number - Number of the container frame presently shown for this bag, or nil if no container frame is shown for this bag

Example

local container = IsBagOpen(0)
if (IsBagOpen(0)) then
  -- The backpack is open
  _G["ContainerFrame" .. container]:Hide()  -- But now its closed
end

Details

  • Even though the return is a number, it may be treated as a boolean for conditional logic:
    • If the bag is open, the number returned will always evaluate to true
    • If the bag is closed, the nil returned will always evaluate to false
  • When open, bags appear as a ContainerFrame called ContainerFrame1, ContainerFrame2, etc.
  • The number returned by this function informs you which ContainerFrame currently corresponds to this BagID
  • ContainerFrame:GetID() returns the BagID value

Patch changes

WoW Icon update.png Patch 1.11.0 (2006-06-19): Returns the BagID (number) of the corresponding ContainerFrame.[1]

  • Previously returned boolean (1 or nil).

See Also

References

 
  1. ^ ContainerFrame.lua version 1.11.0.5428 archived at Townlong Yak]