mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
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.
This commit is contained in:
+5
-5
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user