fix itemid extraction and cost capture for regeants

This commit is contained in:
Jrc13245
2025-08-27 21:50:53 -04:00
parent cc9198e940
commit 86df1583c4
+6 -5
View File
@@ -82,12 +82,13 @@ function CleveRoids.GetReagentCount(reagentName)
for bag = 0, 4 do
local slots = GetContainerNumSlots(bag) or 0
for slot = 1, slots do
local count = select(2, GetContainerItemInfo(bag, slot)) or 0
local _, count = GetContainerItemInfo(bag, slot)
count = count or 0
-- Prefer link → id when available
local link = (GetContainerItemLink and GetContainerItemLink(bag, slot)) or nil
if link then
local id = tonumber(string.find(link, "item:(%d+)"))
local _, _, idstr = string.find(link, "item:(%d+)")
local id = idstr and tonumber(idstr) or nil
if (wantId and id == wantId) or (not wantId and string.find(link, "%["..reagentName.."%]")) then
total = total + (count > 0 and count or 1)
end
@@ -159,8 +160,8 @@ function CleveRoids.GetSpellCost(spellSlot, bookType)
end
if not cost and rt ~= "" then
local n = string.find(rt, "^(%d+)%s+(Mana|Energy|Rage|Focus)")
if n then cost = tonumber(n) end
local _, _, num = string.find(rt, "^(%d+)%s+(Mana|Energy|Rage|Focus)")
if num then cost = tonumber(num) end
end
if reagent and cost then break end