WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID not firing? (https://www.wowinterface.com/forums/showthread.php?t=57919)

Xruptor 04-09-20 08:20 AM

SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID not firing?
 
So I'm having this bizarre issue where SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID are not firing at all when hovering over a token cost in token vendors. Such as War Resources or Honor Tokens and such.

I've tried several methods to figure out why they aren't firing and can only assume another hidden function is being used for GameTooltip. I know it has to do with AltCurrency but can't seem to figure out how to grab the CurrencyID or token being fired for the GameTooltip. Some of these token currencies are pushed to AltCurrencyFrame_Update. Yet not matter what I do or what I hook, I cannot get the token currency to fire for GameTooltip.

Does anyone have any ideas?

I've tried the following.

Code:


                hooksecurefunc(GameTooltip, "SetCurrencyToken", function(self, index)
                print('SetCurrencyToken', self, index)

                end)
                hooksecurefunc(GameTooltip, "SetCurrencyTokenByID", function(self, currencyID)
                print('SetCurrencyToken', self, currencyID)

                end)
                hooksecurefunc(GameTooltip, "SetCurrencyByID", function(self, currencyID)
                print('SetCurrencyByID', self, currencyID)

                end)

None of the above works when you hover over a token under a token vendor. Like I said the only thing I can assume is that it's not GameTooltip being used or the Currency is being set by a hidden function. That or it's being passed somehow differently.

The ONLY thing that seems to work is to hook into the token frames themselves under the merchant frame.


Code:

                hooksecurefunc("MerchantFrame_UpdateAltCurrency", function(index, indexOnPage, canAfford)
                        local itemCount = GetMerchantItemCostInfo(index)
                        local frameName = "MerchantItem"..indexOnPage.."AltCurrencyFrame"
                        local usedCurrencies = 0

                        -- update Alt Currency Frame with itemValues
                        if ( itemCount > 0 ) then
                                for i=1, MAX_ITEM_COST do
                                        local itemTexture, itemValue, itemLink = GetMerchantItemCostItem(index, i)
                                        if ( itemTexture ) then
                                                usedCurrencies = usedCurrencies + 1
                                                if not _G[frameName.."Item"..usedCurrencies].isHooked then
                                                        _G[frameName.."Item"..usedCurrencies]:HookScript("OnEnter", function()
                                                          print('currency', itemLink)
                                                        end)
                                                        _G[frameName.."Item"..usedCurrencies].isHooked = true
                                                end
                                        end
                                end
                        end
                       
                end)

this code also works, pretty much the same as above but going directly to AltCurrency

Code:


                local oldAltCurrencyFrame_Update = AltCurrencyFrame_Update
                AltCurrencyFrame_Update = function(frameName, texture, cost, canAfford)
                        if _G[frameName] and _G[frameName].itemLink then
                                if not _G[frameName].isHooked then
                                        _G[frameName]:HookScript("OnEnter", function()
                                              print(_G[frameName].itemLink)
                                        end)
                                        _G[frameName].isHooked = true
                                end
                                print(frameName, texture, cost, canAfford, _G[frameName].itemLink)
                        end
                        oldAltCurrencyFrame_Update(frameName, texture, cost, canAfford)
                end

Does anyone have any idea of what's going on?

Ketho 04-09-20 04:54 PM

Quote:

Originally Posted by Xruptor (Post 335592)
where SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID are not firing at all when hovering over a token cost in token vendors.


Can you try hooking GameTooltip:SetMerchantCostItem()

https://github.com/Gethe/wow-ui-sour...Frame.xml#L328

Xruptor 04-10-20 07:16 AM

Quote:

Originally Posted by Ketho (Post 335595)
Can you try hooking GameTooltip:SetMerchantCostItem()

https://github.com/Gethe/wow-ui-sour...Frame.xml#L328

I think I tried that one before, but I'll give it a whirl and see. I wouldn't be surprised if it was one of those hidden or not very documented functions. Thanks for the suggestion!

Xruptor 04-10-20 06:59 PM

Quote:

Originally Posted by Ketho (Post 335595)
Can you try hooking GameTooltip:SetMerchantCostItem()

https://github.com/Gethe/wow-ui-sour...Frame.xml#L328

Okay yep that was it. Apparently that particular function is only use for those specific token situations. Otherwise the others are used. It's quite an obscure function as it's not really documented anywhere properly. I had to tweak the code but it works. You basically have to work with the merchant item index and the index of the currency from GetMerchantCurrencies(). Since apparently some items are paid with multiple token currencies.

Many thanks for your help! It was driving me crazy. Here is the code that works.

Code:

                hooksecurefunc(objTooltip, "SetMerchantCostItem", function(self, index, currencyIndex)

                        local currencyID = select(currencyIndex, GetMerchantCurrencies())
                        if currencyID then
                                local name, currentAmount, icon, earnedThisWeek, weeklyMax, totalMax, isDiscovered, rarity = GetCurrencyInfo(currencyID)
                                if name and icon then
                                        print(name, icon, currencyID)
                                end
                        end

                end)



All times are GMT -6. The time now is 08:12 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI