From 269c6ba67e3ddee769f2095674e0d081677c3d63 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed, 9 Sep 2026 02:40:57 -0500 Subject: [PATCH] Fix the same 0-based slot assumption in the equipment Lua fallbacks #2 corrected IsItemInSlot's native path, but the same 0-based assumption was still present in the two Lua fallbacks, which run on nampower < v2.18. Per nampower's SCRIPTS.md the slot is 1-19 (16=MainHand, 17=OffHand), and ClassicAPI's GetInventoryItemID is 1-based as well: - GetEquippedItem's fallback called GetInventoryItemID(slot + 1), contradicting both its own native path and its doc comment. - GetEquippedItems' fallback built 0-18 keys while the native path returns 1-19, so the two branches handed back differently-keyed tables. Neither wrapper currently has any callers, so this was latent rather than user-visible. Also records the 1-indexed convention at the IsItemInSlot call site, where the misleading "0-indexed" comment used to be. --- NampowerAPI.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NampowerAPI.lua b/NampowerAPI.lua index abc74d1..ce6d016 100644 --- a/NampowerAPI.lua +++ b/NampowerAPI.lua @@ -1474,7 +1474,7 @@ end -- Get all equipped items for a unit -- Requires v2.18+ for native GetEquippedItems (with Lua fallback for player only) --- Returns table with slot indices (0-18) as keys, item info tables as values +-- Returns table with slot indices (1-19) as keys, item info tables as values function API.GetEquippedItems(unitToken) unitToken = unitToken or "player" @@ -1489,8 +1489,8 @@ function API.GetEquippedItems(unitToken) end local items = {} - for slot = 0, 18 do - local itemId = CleveRoids.ClassicAPI.GetInventoryItemID("player", slot + 1) + for slot = 1, 19 do + local itemId = CleveRoids.ClassicAPI.GetInventoryItemID("player", slot) if itemId then items[slot] = { itemId = itemId, @@ -1518,7 +1518,7 @@ function API.GetEquippedItem(unitToken, slot) return nil end - local itemId = CleveRoids.ClassicAPI.GetInventoryItemID("player", slot + 1) -- 1-indexed + local itemId = CleveRoids.ClassicAPI.GetInventoryItemID("player", slot) -- both are 1-indexed if itemId then return { itemId = itemId, @@ -1672,7 +1672,7 @@ function API.IsItemInSlot(itemIdOrName, inventorySlot) -- Use native v2.18 GetEquippedItem if available if GetEquippedItem then - local slotInfo = GetEquippedItem("player", inventorySlot) + local slotInfo = GetEquippedItem("player", inventorySlot) -- 1-indexed (1-19) if slotInfo and slotInfo.itemId then local checkId = tonumber(itemIdOrName) if checkId then