Originally Posted by Gethe
It depends on 1) when the mixin is created 2) when the function is hooked and 3) when the frame has the mixin applied.
In Ammako's case, ExpBarMixin is created and is applied to a template in the frame xml, before any addon gets loaded. The template however is not used for instantiating a frame until PLAYER_ENTERING_WOLRD fires, which is typically after most addons are loaded. As such, any hooks applied to the mixin before PLAYER_ENTERING_WOLRD fires will propagate the the new frame.
In Nikita's case, MainMenuBarMixin is created and immediately used in the creation of MainMenuBar. This means there is no allowance for any hooks to be made and applied via the mixin.
|
The thing that is confusing me, is hoocsecurefunc sometimes toggle lua errors like "funxtionX is not a function"
For example, I tried to hook some functions like
function PlayerTalentFrame_UpdateSpecFrame(self, spec) from Blizzard_TalentUI.lua:
Lua Code:
function PlayerTalentFrame_UpdateSpecFrame(self, spec)
local playerTalentSpec = GetSpecialization(nil, self.isPet, specs[selectedSpec].talentGroup);
local shownSpec = spec or playerTalentSpec or 1;
local numSpecs = GetNumSpecializations(nil, self.isPet);
local petNotActive = self.isPet and not IsPetActive();
local sex = self.isPet and UnitSex("pet") or UnitSex("player");
-- and so on... very large function
end
So I used this code:
Lua Code:
local function Test(self, spec)
print("test")
print(self)
print(spec)
end
hooksecurefunc('PlayerTalentFrame_UpdateSpecFrame', Test)
And got this: Error. hooksecurefunc(): PlayerTalentFrame_UpdateSpecFrame is not a function
At the same time, for example:
Lua Code:
local function Test(self, spec)
print("test")
print(self)
print(spec)
end
hooksecurefunc('SpellBookFrame_UpdateSkillLineTabs', Test)
Works perfectly.
Can't understand why this happens, and will appreciate any advises how to hook functions with "funxtionX is not a function" error.