WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Identify items on refund cooldown (https://www.wowinterface.com/forums/showthread.php?t=57947)

Walkerbo 04-16-20 11:52 PM

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?


myrroddin 04-17-20 01:59 AM

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.

Walkerbo 04-19-20 11:33 PM

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;
Quote:

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?

Kanegasi 04-20-20 12:16 AM

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

Walkerbo 04-20-20 03:59 AM

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;

Vrul 04-20-20 07:53 AM

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)

Walkerbo 04-20-20 11:49 PM

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.

Xrystal 04-21-20 07:43 AM

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.

Vrul 04-21-20 02:16 PM

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.

Walkerbo 04-21-20 09:43 PM

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.

Vrul 04-21-20 11:02 PM

Quote:

Originally Posted by Walkerbo (Post 335732)
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.

Quote:

Originally Posted by Walkerbo (Post 335732)
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?

Walkerbo 04-24-20 10:33 PM

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.

myrroddin 04-25-20 02:05 AM

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?

Walkerbo 04-29-20 05:26 AM

Hi myrroddin

Aardvark is a stand alone sell, destroy and repair addon.:)


All times are GMT -6. The time now is 08:31 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI