View Single Post
10-25-20, 09:05 PM   #6
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Hi Urtgard

I used the same code and added an or as follows;
Lua Code:
  1. if(string.find(_G["TooltipTextLeft"..i]:GetText(), string.format(BIND_TRADE_TIME_REMAINING, ".*"))) or
  2.  (string.find(_G["TooltipTextLeft"..i]:GetText(), string.format(REFUND_TIME_REMAINING, ".*"))) then
  3.         return true
  4. end
and an elseif;
Lua Code:
  1. if(string.find(_G["TooltipTextLeft"..i]:GetText(), string.format(BIND_TRADE_TIME_REMAINING, ".*"))) then
  2.         return true
  3.       elseif(string.find(_G["TooltipTextLeft"..i]:GetText(), string.format(REFUND_TIME_REMAINING, ".*"))) then
  4.         return true
  5.       end
I also tried an elseif, but for some reason, I was only getting true on items that could be traded.

Right now I am using a combination of your tooltip scan code and getting the refund seconds as follows,
Lua Code:
  1. local function isTradable(itemLocation)
  2.    local itemLink = C_Item.GetItemLink(itemLocation)
  3.    tip:SetOwner(UIParent, "ANCHOR_NONE")
  4.    tip:SetBagItem(itemLocation:GetBagAndSlot())
  5.    for i = 1,tip:NumLines() do
  6.       if(string.find(_G["TooltipTextLeft"..i]:GetText(), string.format(BIND_TRADE_TIME_REMAINING, ".*"))) then
  7.         return true
  8.       end
  9.    end
  10. end
  11.    
  12. for bag = 0, 4 do
  13.     for slot = 0, GetContainerNumSlots(bag) do
  14.         local itemID = GetContainerItemID(bag, slot)
  15.         if itemID then
  16.             local _, itemLink = GetItemInfo(itemID)
  17.             local money, itemCount, refundSec = GetContainerItemPurchaseInfo(bag, slot)
  18.             local itemLocation = ItemLocation:CreateFromBagAndSlot(bag, slot)            
  19.             if isTradable(itemLocation) or refundSec then
  20.                 print("found",itemLink)
  21.             end
  22.         end
  23.     end
  24. end

I just wish I could understand why scanning the tooltip works for one but not the other.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote