Loading...

hookscript of ReputationBar

1
Is it possible to hook the reputation bar's OnEnter script ? I want to add the reps of the other factions to the bar.

I've tried " ElvUI_ReputationBar " and " ElvUI_ReputationBarHolder " from /fstack command, but get "Attempt to index, a nil value "

I have also tried DB:ReputationBar:HookScript, but the same error message.

Thank you

hookscript of ReputationBar

2
This is what I am using, with AceHook-3.0. Please note the function I am calling is a local function named exactly the same as ElvUI's function. That was so I could keep track of what a function is doing, as I have many functions. If you want to use a "normal" function, see after the jump.

Code: Select all

local E, L, V, P, G = unpack(ElvUI) -- import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local EDB = E:GetModule("DataBars") -- ElvUI's DataBars

function EPDBC:HookRepTooltip()
    local bar = EDB.StatusBars.Reputation
    if E.db.EPDBC.enabled and bar then
        if not EPDBC:IsHooked(EDB, "ReputationBar_OnEnter") then
            EPDBC:SecureHook(EDB, "ReputationBar_OnEnter", ReputationBar_OnEnter) -- hooked local function named ReputationBar_OnEnter
        end
    elseif not E.db.EPDBC.enabled or not bar then
        if EPDBC:IsHooked(EDB, "ReputationBar_OnEnter") then
            EPDBC:Unhook(EDB, "ReputationBar_OnEnter")
        end
    end
end
Here is the non-local version, if you wanted to call MyAddon:SomeFunction()

Code: Select all

EPDBC:SecureHook(EDB, "ReputationBar_OnEnter", MyAddon.SomeFunction)