container: add C_Container.HasContainerItem

Classic Era addition (present in the 1.15.x client, absent in 5.4.8) — a
plain occupancy check for a bag slot. Occupancy sibling of
GetContainerItemID: resolves (bagIndex, slotIndex) the same way and returns
whether the CGItem is non-null. Presence only, so it reports true for a
just-looted item even before its static data caches. Returns false for
empty slots and out-of-range indices.
This commit is contained in:
Brues
2026-07-17 00:37:23 -05:00
parent e1030213d3
commit 3afd403eae
3 changed files with 73 additions and 1 deletions
+20
View File
@@ -40,6 +40,7 @@ build instructions.
- [Container](#container)
- [`C_Container.GetContainerItemID(bagIndex, slotIndex)`](#c_containergetcontaineritemidbagindex-slotindex)
- [`C_Container.HasContainerItem(bagIndex, slotIndex)`](#c_containerhascontaineritembagindex-slotindex)
- [`GetItemCooldown(itemInfo)` / `C_Container.GetItemCooldown(itemID)`](#getitemcooldowniteminfo--c_containergetitemcooldownitemid)
- [`C_Container.GetContainerItemDurability(containerIndex, slotIndex)`](#c_containergetcontaineritemdurabilitycontainerindex-slotindex)
- [`C_Container.GetContainerItemRepairCost(containerIndex, slotIndex)`](#c_containergetcontaineritemrepaircostcontainerindex-slotindex)
@@ -1061,6 +1062,25 @@ for slot = 1, 16 do
end
```
### `C_Container.HasContainerItem(bagIndex, slotIndex)`
Returns `true` if the given bag slot currently holds an item, `false`
otherwise (empty slot or out-of-range indices). The occupancy sibling of
`GetContainerItemID` — same slot resolution, but a plain presence check.
- `bagIndex = 0` — the player's main backpack; `1..4` — equipped bag slots.
- `slotIndex` — 1-based.
Presence only: it does **not** require the item's static data to be cached,
so it returns `true` for a just-looted item even before `GetContainerItemID`
/ `GetItemInfo` resolve for it.
```lua
if C_Container.HasContainerItem(0, 1) then
-- backpack slot 1 is occupied
end
```
### `GetItemCooldown(itemInfo)` / `C_Container.GetItemCooldown(itemID)`
Returns `(startTime, duration, enable)` for the cooldown of the