hooksecurefunc works on funcA, but not on funcB
So I'm attempting to add some code to a global function for VuhDo.
Unfortunately I cant seem to figure out why I can hook a func to 'function A', but not to 'function B' [WORKS] Function A (VuhDo -> VuhDoDebuffs.lua): Code:
function VUHDO_determineDebuff(aUnit) Code:
function VUHDO_customizeText(aButton, aMode, anIsTarget) Code:
local f = CreateFrame("Frame") Note: on function A I dont need to comment out anything. It always works :/ Code:
--local VUHDO_customizeText = VUHDO_customizeText; Code:
_G["VUHDO_customizeText"] --this exists, can I safely assume its a global function and it should work? |
Not actually a solution to your issue, but PLAYER_ENTERING_WORLD fires at more than just player login, so you may want to make sure your code won't be creating multiple hooks as a result. Wasteful at best, harmful at worst if the hooks end up interfering with each other or causing performance issues. :p
ADDON_LOADED may be a better choice, but keep in mind that would require your addon to load before VuhDo does. |
Just hook the global function rather than trying to localise it first. Other than that, without the actual code it's a bit hard to tell what might be going on.
PLAYER_LOGIN fires after all the ADDON_LOADEDs and before PLAYER_ENTERING_WORLD and only fires once. |
Without checking the files I would guess that function A hook is working because Vuhdo is actually calling VUHDO_determineDebuff from outside file VuhDoDebuffs.lua and in those files the local version does not exist.
On the other hand VUHDO_customizeText is being called from within the files VuhDoBarCustomizerHealth.lua where local version is called instead of the global version. When you hook a function you in fact make another function but the local version is pointing to a pre hook version. You can confirm with this macro Code:
/run function a()print("function")end local f=a hooksecurefunc("a",function()print("hook")end) local g=a f()g() whereas g() call does call the hook function because it is a local reference to the hooked global function a. |
All times are GMT -6. The time now is 04:48 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI