How can I hooksecurefunc with colon like this: "MainMenuBarMixin:OnShow"
I spend so much time trying to figure it out by myself, but unfortunately no luck.
This is blizard code mainMenuBar.lua: Code:
local MAINMENU_SLIDETIME = 0.30; Code:
local function Test() |
Anything with "mixin" in it's name isn't actually used directly, so if you were to hook that function, the hook won't get called. You'll need to hook the actual method on the frame that uses the mixin.
Mixins are a template of methods that frames then inherit. Blizzard gives frames a mixin template in two ways: calling frame = CreateFromMixins(mixin) or in xml using the mixin="" attribute. In this case, MainMenuBar gets its methods from MainMenuBar.xml: XML Code:
You should be able to do this: Lua Code:
|
Quote:
Kanegasi you saved my day! Thank you very much for explanation. I hope this thread will be helpful for all beginners or coming back modders. Very appreciate your help. I think it's new thing from Legion maybe, don't remember mixins in Pandaria-Warlords of Draenor. |
Quote:
It's interesting to me that you would say that, because this works for me: lua Code:
Maybe it depends on the mixin? idk |
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. |
Quote:
For example, I tried to hook some functions like function PlayerTalentFrame_UpdateSpecFrame(self, spec) from Blizzard_TalentUI.lua: Lua Code:
Lua Code:
At the same time, for example: Lua Code:
Can't understand why this happens, and will appreciate any advises how to hook functions with "funxtionX is not a function" error. |
Quote:
|
All times are GMT -6. The time now is 08:07 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI