WoWInterface - View Single Post - Identify items that can be traded to other players in the same instance.
View Single Post
10-18-20, 08:28 PM   #4
A Flamescale Wyrmkin
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 127
Hi all

Sorry for the delayed reply.

Thanks for the links and code chunk.

Here is the current code;
Lua Code:
  1. local tip = CreateFrame("GameTooltip","Tooltip",nil,"GameTooltipTemplate")
  3. local function isTradable(itemLocation)
  4.    local itemLink = C_Item.GetItemLink(itemLocation)
  5.    tip:SetOwner(UIParent, "ANCHOR_NONE")
  6.    tip:SetBagItem(itemLocation:GetBagAndSlot())
  7.    for i = 1,tip:NumLines() do
  8.       if(string.find(_G["TooltipTextLeft"..i]:GetText(), string.format(BIND_TRADE_TIME_REMAINING, ".*"))) then
  9.         return true
  10.       end
  11.    end
  12. end
  14. for bag = 0, 4 do
  15.     for slot = 0, GetContainerNumSlots(bag) do
  16.         local itemID = GetContainerItemID(bag, slot)
  17.         if itemID then
  18.             local _, itemLink = GetItemInfo(itemID)
  19.             itemLocation = ItemLocation:CreateFromBagAndSlot(bag, slot)            
  20.             if isTradable(itemLocation) then
  21.             print("found",itemLink,isTradable(itemLocation))
  22.             end
  23.         end
  24.     end
  25. end

This works perfectly.

What I am wondering is I also want to be able to idently those items that can be sold back to the venror for a full refund.
The string I have to look for is REFUND_TIME_REMAINING yet when I try to find the string I get no matches.

Is it possible to search for either or both of the strings in the same loop?
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
  Reply With Quote