Help: coverting a UI script into an addon

Hi all,

I’m not at all experienced with making addons and I’m having some trouble getting some of my UI scripts to work in addon form. I have been running these in macros in WoW Classic but I’d like to have them run in an addon.

MainMenuBarTexture0:SetTexture(nil)
MainMenuBarTexture1:SetTexture(nil)
MainMenuBarTexture2:SetTexture(nil)
MainMenuBarTexture3:SetTexture(nil)
MainMenuMaxLevelBar0:SetTexture(nil)
MainMenuMaxLevelBar1:SetTexture(nil)
MainMenuMaxLevelBar2:SetTexture(nil)
MainMenuMaxLevelBar3:SetTexture(nil)

This is what I’m trying to get to work – it seems that only the first and second lines are running. Is this because the other elements haven’t loaded yet?

I would really appreciate any help!

Slap it into https://addon.bool.no/

Thanks Elvenbane! I did actually use that website to create the addon and that helped me confirm it was loading.

I have just managed to get the addon to work by using SetAlpha(0) instead of SetTexture(nil)! I would be interested to know if anyone knows why this works instead?

Best guess, your addon was nil-ing the texture before it was being initially set because it’s not using any event based programming to determine when it should execute. Whereas alpha is just being defaulted rather than being set by the core addons.

Ah makes sense – thanks for your input!

This function is calling SetTexture on MainMenuBarTexture2 and MainMenuBarTexture3
https://sourcegraph.com/github.com/Gethe/wow-ui-source@ae1775febdd170796b48d19ca6a748e29bad25f1/-/blob/Interface/FrameXML/MainMenuBar.lua?L665

It’s being called on PLAYER_ENTERING_WORLD, VARIABLES_LOADED and BAG_UPDATE from here
https://sourcegraph.com/github.com/Gethe/wow-ui-source@ae1775febdd170796b48d19ca6a748e29bad25f1/-/blob/Interface/FrameXML/MainMenuBar.lua?L99

To override that you could disable your keyring entirely with the cvar showKeyring or add something like this

local function hookSetTexture(frameName)
    local frame = _G[frameName]
    local hookEnabled = true     -- to prevent infinite recursion
    hooksecurefunc(frame, "SetTexture", function() 
        if hookEnabled then 
            hookEnabled = false 
            frame:SetTexture(nil) 
            hookEnabled = true
        end 
    end)
end
    
hookSetTexture("MainMenuBarTexture2")
hookSetTexture("MainMenuBarTexture3")

As for MainMenuMaxLevelBar, I don’t know what that is supposed to be so not sure about that one. For me, SetTexture never gets called on any of those frames after loading.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.