Addon error "BackpackTokenFrame_Update"

Trying to fix an addon that calls for secure func “BackpackTokenFrame_Update”, and I cannot find anything about where Blizz removed/replaced it. Anyone know anything?

Error:

Message: Interface/AddOns/Broker_Wallet/Broker_Wallet.lua line 87:
hooksecurefunc(): BackpackTokenFrame_Update is not a function
Debug:
[string “=[C]”]: hooksecurefunc()
[string “@Interface/AddOns/Broker_Wallet/Broker_Wallet.lua”]:87: in main chunk
Locals:

Chat AI gave me this snippet, but I don’t want to kill functionality (addon=broker for currency)

>  local function SafeHookFunction(funcName, hookFunc)
>         if _G[funcName] then
>             hooksecurefunc(funcName, hookFunc)
>         else
>             print("Error: Function '" .. funcName .. "' does not exist.")
>         end
>     end
> 
>     SafeHookFunction("BackpackTokenFrame_Update", function()
>         -- Your hook code here
>     end)

Looks like it was last used in 9.2.7


function BackpackTokenFrame_Update()
	for i=1, MAX_WATCHED_TOKENS do
		local watchButton = BackpackTokenFrame.Tokens[i];
		local currencyInfo = C_CurrencyInfo.GetBackpackCurrencyInfo(i);

		if currencyInfo then
			local count = currencyInfo.quantity;
			watchButton.icon:SetTexture(currencyInfo.iconFileID);

			local currencyText = BreakUpLargeNumbers(count);
			if strlenutf8(currencyText) > 5 then
				currencyText = AbbreviateNumbers(count);
			end

			watchButton.count:SetText(currencyText);
			watchButton.currencyID = currencyInfo.currencyTypesID;
			watchButton:Show();

			BackpackTokenFrame.shouldShow = true;
			BackpackTokenFrame.numWatchedTokens = i;
		else
			watchButton:Hide();
			if i == 1 then
				BackpackTokenFrame.shouldShow = nil;
			end
		end
	end
end
1 Like

Uses a mixin now.
https://github.com/Gethe/wow-ui-source/blob/live/Interface/AddOns/Blizzard_TokenUI/Blizzard_TokenUI.lua#L301

2 Likes

So, replace this:

hooksecurefunc( “BackpackTokenFrame_Update”, Wallet.BackpackUpdate)

with this:

hooksecurefunc(TokenFrame,“Update”,Wallet.BackpackUpdate)

Got this from Xrystal over on the WoWInterface forums, seems to have worked.