Thread Tools Display Modes
04-20-22, 06:12 PM   #1
dafou
A Defias Bandit
Join Date: Apr 2022
Posts: 2
Hooking Scripts on game frames

Hey everyone,

I’m trying to work on addons and I’m running into an issue.

When trying to hook a function onto an existing frame OnShow like “SouldbindViewer”, “GarrisonLandingPage” or “PlayerTalentsFrame”, it simply doesn’t work.

But it does work on my custom Frames or on other Frames like “ChatFrame1”.

I’m wondering if I’m missing something here ?
  Reply With Quote
04-20-22, 08:25 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
Those all seem to be frames from Load On Demand addons so you're probably trying to hook them before they exist.

What you need to do is find the Blizzard addon they belong to.
Create a frame and register it to recieve the ADDDON_LOADED event.
Check which addon loaded and if it's one of yours, hook the script eg.

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("ADDON_LOADED")
  3. f:SetScript("OnEvent", function(self, event, addonname)
  4.     if addonname == "Blizzard_GarrisonUI" then
  5.         GarrisonLandingPage:HookScript("OnShow", function(self)
  6.             -- do whatever
  7.         end)
  8.     elseif addonname == "One of the other addons" then
  9.         -- do whatever else
  10.     end
  11. end)
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-20-22 at 09:15 PM.
  Reply With Quote
04-21-22, 06:55 AM   #3
dafou
A Defias Bandit
Join Date: Apr 2022
Posts: 2
Ooooh I see this makes way more sense !

This worked and I found a list of all Blizzard addons to check if they load with them.

Thank you for the quick reply, all I did was to wait for VARIABLES_LOADED but I didn't know these were part of addons
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hooking Scripts on game frames

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