add item count support for inbag/noinbag conditional, fix macro frame whitelist and error log on macro frame

This commit is contained in:
Jrc13245
2026-03-21 12:03:46 -04:00
parent 0e6371692e
commit 5bb8ebe9b7
3 changed files with 19 additions and 4 deletions
+14
View File
@@ -5907,17 +5907,31 @@ CleveRoids.Keywords = {
end,
-- [inbag:Item] — true if item exists in bags or equipped
-- [inbag:Item<12] — true if bag count of Item is less than 12
-- Supports multi-value: [inbag:Item1/Item2 inbag:Item3] = (Item1 OR Item2) AND Item3
inbag = function(conditionals)
return Multi(conditionals.inbag, function(v)
if type(v) == "table" and v.operator and v.amount then
local count = CleveRoids.GetLiveItemCount(v.name)
local cmp = CleveRoids.comparators[v.operator]
if not cmp then return false end
return cmp(count, v.amount)
end
return CleveRoids.HasItem(v)
end, conditionals, "inbag")
end,
-- [noinbag:Item] — true if item is NOT in bags or equipped
-- [noinbag:Item<12] — true if bag count of Item is NOT less than 12 (i.e. >= 12)
-- [noinbag:X/Y] = X not in bags AND Y not in bags (De Morgan's)
noinbag = function(conditionals)
return NegatedMulti(conditionals.noinbag, function(v)
if type(v) == "table" and v.operator and v.amount then
local count = CleveRoids.GetLiveItemCount(v.name)
local cmp = CleveRoids.comparators[v.operator]
if not cmp then return true end
return not cmp(count, v.amount)
end
return not CleveRoids.HasItem(v)
end, conditionals, "noinbag")
end,
+2 -1
View File
@@ -687,12 +687,13 @@ function CleveRoids.GetLiveItemCount(itemName)
-- Escape Lua pattern special chars in item name to avoid crashes
local escaped = string.gsub(itemName, "([%(%)%.%%%+%-%*%?%[%]%^%$])", "%%%1")
local pattern = "%[" .. escaped .. "%]"
local lowerPattern = string.lower(pattern)
local total = 0
for bag = 0, 4 do
local slots = GetContainerNumSlots(bag) or 0
for slot = 1, slots do
local link = GetContainerItemLink and GetContainerItemLink(bag, slot)
if link and string.find(link, pattern) then
if link and string.find(string.lower(link), lowerPattern) then
local _, count = GetContainerItemInfo(bag, slot)
total = total + (count or 0)
end
+3 -3
View File
@@ -62,8 +62,8 @@ local function CreateErrorPanel()
-- Anchor to the scroll frame (text edit area) instead of the full MacroFrame,
-- which can extend far below the visible UI on extended macro clients
local scrollRef = MacroFrameScrollFrame or MacroFrame
panel:SetPoint("TOPLEFT", scrollRef, "BOTTOMLEFT", -20, -27)
panel:SetPoint("TOPRIGHT", scrollRef, "BOTTOMRIGHT", 0, -27)
panel:SetPoint("TOPLEFT", scrollRef, "BOTTOMLEFT", -20, -47)
panel:SetPoint("TOPRIGHT", scrollRef, "BOTTOMRIGHT", 0, -47)
panel:SetHeight(1)
panel:SetFrameStrata("DIALOG")
panel:SetBackdrop({
@@ -549,7 +549,7 @@ local function CreateWhitelistButton()
local btn = CreateFrame("Button", "CleveRoidsWhitelistButton", MacroFrame)
btn:SetWidth(80)
btn:SetHeight(18)
btn:SetPoint("BOTTOMRIGHT", MacroFrame, "BOTTOMRIGHT", 8, 52)
btn:SetPoint("BOTTOMRIGHT", MacroFrame, "BOTTOMRIGHT", 8, 32)
btn:SetFrameStrata("DIALOG")
-- pfUI pixel-perfect flat style