Quantcast
Identify items on refund cooldown - WoWInterface
Thread Tools Display Modes
04-16-20, 11:52 PM   #1
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Identify items on refund cooldown

Hi all

I am the author of a small addon Aardvark.

I am trying to find a way to identify those items in my bags that can be sold back to the vendor for a full refund.

Right now my addon sells items listed on player curated sell list.

The issue is that items that have a value but are still within their refund time cannot be sold but the sell function equips the item instead.

"You may sell this item to a vendor within 1 hour and 50 min for a full refund"

Is there a way to identify items in my bag that are currently on their refund cooldown?

  Reply With Quote
04-17-20, 01:59 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,124
Iterate your items and then scan the tooltip one each one. When you find a matching string REFUND_TIME_REMAINING then you have found your item.

https://www.townlong-yak.com/framexm...balStrings.lua

Line 12151.
  Reply With Quote
04-19-20, 11:33 PM   #3
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Hi myrroddin

Thanks for your help.

Unfortuantley when I scan the item tooltip I still cannot see the refund string.

This is the code I use to scan the tooltip;
local scantip = CreateFrame("GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")

local function MyGetItemStats(link)
scantip:SetHyperlink(link)
for i=1, scantip:NumLines() do
local textL = _G["MyScanningTooltipTextLeft"..i]:GetText()
local textR = _G["MyScanningTooltipTextRight"..i]:GetText()
print(i,textL, textR)
end
end

MyGetItemStats("|cffa335ee|Hitem:41656::::::::111:259::::::|h[Relentless Gladiator's Leather Legguards]|h|r")
This is the item;


This is the output;



Is there a step that I am missing or is there another way that will allow me to identify an item that is on the refund cooldown?
  Reply With Quote
04-20-20, 12:16 AM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 507
Try using GetRegions:

Lua Code:
  1. local regions={scantip:GetRegions()}
  2. for i=1,#regions do
  3.     if regions[i].GetText and regions[i]:GetText() then
  4.         print(regions[i]:GetName(),":",regions[i]:GetText())
  5.     end
  6. end
  Reply With Quote
04-20-20, 03:59 AM   #5
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Hi Kanegasi

Thanks for that, unfortunately GetRegions returns the same info.

My code;
Code:
local scantip = CreateFrame("GameTooltip", "MyScanningTooltip", nil, "GameTooltipTemplate")
scantip:SetOwner(UIParent, "ANCHOR_NONE")

local function MyGetItemStats(link)
   scantip:SetHyperlink(link)
   local regions={scantip:GetRegions()}
   for i=1,#regions do
       if regions[i].GetText and regions[i]:GetText() then
           print(i," - ",regions[i]:GetName(),":",regions[i]:GetText())
       end
   end
end

MyGetItemStats("|cffa335ee|Hitem:41656::::::::111:259::::::|h[Relentless Gladiator's Leather Legguards]|h|r")
My output;
  Reply With Quote
04-20-20, 07:53 AM   #6
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 368
I don't think an itemLink has refund information embedded in it. You will need to use an inventory function with bag, slot arguments to identify an exact item. My best guess is the 3rd return of GetContainerItemPurchaseInfo.
Code:
local money, itemCount, refundSec, currencyCount, hasEnchants = GetContainerItemPurchaseInfo(bag, slot, isEquipped)
  Reply With Quote
04-20-20, 11:49 PM   #7
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Hi Vrul

Thanks for suggesting the GetContainerItemPurchaseInfo unfortunately the returns are all coming back as nils, no matter if the boolean is true, false or empty.

This is my code;
Code:
for bag = 0, 4 do 
    for slot = 0, GetContainerNumSlots(bag) do
        local itemID = GetContainerItemID(bag, slot)
        if itemID then
            local _, itemLink, itemQuality, _, _, _, _, _, _, _, itemValue = GetItemInfo(itemID)
            local money, itemCount, refundSec, currencyCount, hasEnchants = GetContainerItemPurchaseInfo(bag, slot, isEquipped)
            print(bag, slot,itemLink, money, itemCount, refundSec, currencyCount, hasEnchants)
        end
    end
end
This is the bag and the output;


This one is really stumping me, any more suggestions would be fantastic.

Last edited by Walkerbo : 04-21-20 at 12:01 AM.
  Reply With Quote
04-21-20, 07:43 AM   #8
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,535
Hmm looking at function ContainerFrame_GetExtendedPriceString(itemButton, isEquipped, quantity) in https://github.com/tomrus88/Blizzard...ainerFrame.lua I am wondering if access to that information is restricted to when you are talking to a merchant ?

Try talking to a merchant and viewing that information then.
__________________
  Reply With Quote
04-21-20, 02:16 PM   #9
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 368
Weird. Just to test I bought a 7th Legionnaire's Cloak. It didn't matter if I was at the vendor or flew away from town. The function returned: 8800000, 0, 7163, 0, false (obviously the 3rd return got smaller each time). The only things that returned nil were ones I could not sell back.
  Reply With Quote
04-21-20, 09:43 PM   #10
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Hi Vrul

Thanks further testing.

I have played with my chunk and finally got some sense out of it.

This my working code;
Lua Code:
  1. for bag = 0, 4 do
  2.     for slot = 0, GetContainerNumSlots(bag) do
  3.        local itemID = GetContainerItemID(bag, slot)
  4.        if itemID then
  5.           local _, itemLink, itemQuality, _, _, _, _, _, _, _, itemValue = GetItemInfo(itemID)
  6.           local money, itemCount, refundSec = GetContainerItemPurchaseInfo(bag, slot, false)
  7.           print(bag, slot,itemLink, "- money:",money, "- count:",itemCount,"- time:", refundSec)
  8.        end
  9.     end
  10.  end

This is the bag and the output;


The strange outcomes are;
  • It only returns for items that do have a cooldown, once the refund time runs out it will return all nils.
  • The item count always returns 0, no matter how many items I have stacked.
  • The loop identifies the first equipped bag but it does not count any of the other equipped bags.

All in all a real bizarre output. I would like to get some better understanding of why the returns are all over the place but for now I am getting the result I need.

Thanks to you all for your help.
  Reply With Quote
04-21-20, 11:02 PM   #11
Vrul
An Onyxian Warder
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 368
Originally Posted by Walkerbo View Post
The item count always returns 0, no matter how many items I have stacked.
I believe the returns would best be described as:
money = How much copper the item can be returned for
itemCount = The number of different items (tokens or such) the item can be returned for
refundSec = How many seconds remain to be able to return the item for a refund
currencyCount = The number of different currencies (from the currency tab) the item can be returned for

You would then need to call GetContainerItemPurchaseItem or GetContainerItemPurchaseCurrency for each (1 to itemCount/currencyCount) to determine which items/currencies would be refunded.

Originally Posted by Walkerbo View Post
The loop identifies the first equipped bag but it does not count any of the other equipped bags.
The bags are numbered starting with 0 but the slots are numbered starting with 1. I would guess returning info for bag=0, slot=0 is a bug?

Last edited by Vrul : 04-22-20 at 08:30 AM. Reason: Clarification
  Reply With Quote
04-24-20, 10:33 PM   #12
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Hi Vrul.

Sorry for the delayed response.

Thanks for the further explanation, it does make sense.

I really do love this community for the all the help and the detailed explanations.
  Reply With Quote
04-25-20, 02:05 AM   #13
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,124
Are you trying to write a plugin for AdiBags that puts those items into a virtual group? Or is this intended to be agnostic to any other inventory AddOn?
  Reply With Quote
04-29-20, 05:26 AM   #14
Walkerbo
A Theradrim Guardian
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 63
Hi myrroddin

Aardvark is a stand alone sell, destroy and repair addon.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Identify items on refund cooldown

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off