Hi all
I used to identify an item was on a refund timer by stepping through the item tooltip and testing each string using string.format(REFUND_TIME_REMAINING, “.*”)
Unfortuantly this no longer works.
With help from others I can now properly step through the tooltip to test each line as follows;
local function testItemString(itemString)
if not itemString then return "" end
itemString = gsub(itemString,"[%$%(%)%*%+%-%.%/%?%[%/%]%^]","%%%1")
itemString = gsub(itemString,"%%%d?$?%a","(.*)")
return itemString
end
local function isRefundable(itemLocation) -- scan tooltip to see if item is on a cooldown
local itemLink = C_Item.GetItemLink(itemLocation)
AardvarkTooltipFrame:SetOwner(UIParent, "ANCHOR_NONE")
AardvarkTooltipFrame:SetBagItem(itemLocation:GetBagAndSlot())
AardvarkTooltipFrame:Show()
for index = 1, AardvarkTooltipFrame:NumLines() do -- step through item tooltip
if testItemString(_G["TooltipTextLeft" .. index]:GetText() == BIND_TRADE_TIME_REMAINING) then
print("found")
return true
end
end
end
The issue is that the testString function returns true on every item in my bags, including mats.
How do I test each tooltip line and correctly return true on an item that is on trade cooldown?
I also need to understand why;
local money, itemCount, refundSec = C_Container.GetContainerItemPurchaseInfo(bag, slot, false)
now returns all nils.
testItemString
returning ""
is returning something (an empty string). For your if statement to evaluate to false it would have to return either false
or nothing (nil
)
if not itemString then return end
or possibly
if not itemString or itemString == "" then
return
end
Missed the second part
C_Container.GetContainerItemPurchaseInfo
now returns a table.
https://warcraft.wiki.gg/wiki/API_C_Container.GetContainerItemPurchaseInfo
local info = C_Container.GetContainerItemPurchaseInfo(xxx)
if info then
local money, itemCount,refundSeconds, currencyCount, hasEnchants = info.money, info.itemCount, info.refundSeconds, info.currencyCount, info.hasEnchants
end
Hi Fizzlemizz
Thanks for the reply, however, I have tried both of your suggested changes without success.
The changes broke the test function.
You’re right, I was in a hurry when I posted the original.
if testItemString(_G["TooltipTextLeft" .. index]:GetText() == BIND_TRADE_TIME_REMAINING)
This is passing a true/false to testItemString as a result of the
_G["TooltipTextLeft" .. index]:GetText() == BIND_TRADE_TIME_REMAINING
because of the right hand bracket being placed at the end of BIND_TRADE_TIME_REMAINING)
Maybe better:
local function testItemString(itemString)
if not itemString then return "" end
itemString = gsub(itemString,"[%$%(%)%*%+%-%.%/%?%[%/%]%^]","%%%1")
itemString = gsub(itemString,"%%%d?$?%a","(.*)")
return itemString
end
local function isRefundable(itemLocation) -- scan tooltip to see if item is on a cooldown
local itemLink = C_Item.GetItemLink(itemLocation)
AardvarkTooltipFrame:SetOwner(UIParent, "ANCHOR_NONE")
AardvarkTooltipFrame:SetBagItem(itemLocation:GetBagAndSlot())
AardvarkTooltipFrame:Show()
for index = 1, AardvarkTooltipFrame:NumLines() do -- step through item tooltip
if testItemString(_G["TooltipTextLeft" .. index]:GetText()) == BIND_TRADE_TIME_REMAINING then
print("found")
return true
end
end
end
so you’re only sending _G["TooltipTextLeft" .. index]:GetText()
to testItemString()
1 Like
Hi Fizzlemizz
I can’t believe that I missed the fact that C_Container.GetContainerItemPurchaseInfo now returns a table.
(such a rookie move).
local info = C_Container.GetContainerItemPurchaseInfo(bag, slot, false)
if info then
local refundSeconds = info.refundSeconds
print(refundSeconds) -- debug --
end