API IsBagOpen

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