From 75e4a37f94afd7cd850830fcc2f47003fcb71d42 Mon Sep 17 00:00:00 2001 From: Jrc13245 Date: Mon, 25 Aug 2025 14:53:15 -0400 Subject: [PATCH] fix spell costs for tools needed in addition to regeants --- Core.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Core.lua b/Core.lua index 0bded8f..173042d 100644 --- a/Core.lua +++ b/Core.lua @@ -36,10 +36,22 @@ end function CleveRoids.GetSpellCost(spellSlot, bookType) CleveRoids.Frame:SetOwner(WorldFrame, "ANCHOR_NONE") CleveRoids.Frame:SetSpell(spellSlot, bookType) - local _, _, cost = string.find(CleveRoids.Frame.costFontString:GetText() or "", "^(%d+) [^ys]") - local _, _, reagent = string.find(CleveRoids.Frame.reagentFontString:GetText() or "", "^Reagents: (.*)") - if reagent and string.sub(reagent, 1, 2) == "|c" then - reagent = string.sub(reagent, 11, -3) + + local costText = CleveRoids.Frame.costFontString:GetText() or "" + local _, _, cost = string.find(costText, "^(%d+) [^ys]") + local line = CleveRoids.Frame.reagentFontString:GetText() or "" + + -- strip color and link wrappers if present + line = line:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):gsub("|H.-|h(.-)|h", "%1") + + -- accept "Reagent(s):" OR "Tool(s):" (case-insensitive), grab what comes after the colon + local reagent = line:match("^%s*[Rr]eagents?:%s*(.+)$") + or line:match("^%s*[Tt]ools?:%s*(.+)$") + + -- if multiple are ever listed, keep the first token + if reagent then + reagent = reagent:match("^[^,]+") + reagent = reagent and reagent:match("^%s*(.-)%s*$") or nil end return (cost and tonumber(cost) or 0), (reagent and tostring(reagent) or nil)