Thread Tools Display Modes
04-09-20, 08:20 AM   #1
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
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?
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }

Last edited by Xruptor : 04-09-20 at 08:47 AM.
  Reply With Quote
04-09-20, 04:54 PM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Xruptor View Post
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

Last edited by Ketho : 04-09-20 at 04:56 PM.
  Reply With Quote
04-10-20, 07:16 AM   #3
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
Originally Posted by Ketho View Post
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!
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
04-10-20, 06:59 PM   #4
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
Originally Posted by Ketho View Post
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)
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }

Last edited by Xruptor : 04-13-20 at 08:42 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetCurrencyByID, SetCurrencyToken and SetCurrencyTokenByID not firing?

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