Addon.bool.no question Scripting help needed

Hi all, I’m trying to auto run scripts on log in to edit my frames and cast bars along with disabling my stance bar and moving my buff/debuff bar down.

When ran macro by macro the changes work just fine, however when I compile them on addon.bool.no and run that addon I only get about half of the UI changes expected.

My first thought it that the objects that are trying to be edited haven’t been loaded but this is my first time trying the site. Any suggestions would be greatly appreciated.

Your ‘first thought’ could very well be correct. Some widgets are load-on-demand, triggered by functions at https://www.townlong-yak.com/framexml/9.1.0/UIParent.lua#518 .

Force the widgets to load right away

A simple, brute-force approach that is easiest if you are doing this for your own use only.

AchievementFrame_LoadUI()
-- now you can modify the appearance of AchievementFrame

Delay your modifications until the widgets appear

Using lua to hook the function, so you can trigger your addon the first time it loads without forcing it to load early. More complicated, but also avoids inefficiency from forcing everything to load needlessly. Only recommended if you are building an addon for other people besides yourself.

The code below checks if the frame exists already – it shouldn’t, but another addon might have triggered it already so this sanity check avoids problems.

local isFirstTime = true

local function yourModifications()
    if (isFirstTime) then

        -- do something cool here

        isFirstTime = false
    end   
end

if (AchievementFrame) then
    yourModifications()
else
    hooksecrefunc("AchievementFrame_LoadUI", yourModifications)
end

Load your addon with the other one

If your modifications are all associated with the same Blizzard frame, then you could also add an instruction to the TOC file to just make it always load immediately after the Blizzard’s does.

This is the cleanest solution, but isn’t suited to big addons that interface with multiple features which may or may not be loaded simultaneously.

## LoadWith Blizzard_AchievementUI
1 Like

Hello, thank you for this detailed response!

When I try to add these lines the addon seems to break and I receive no changes.

PlayerFrame_LoadUI()
TargetFrame_LoadUI()
FocusFrame_LoadUI()
TargetFrameSpellBar_LoadUI()
FocusFrameSpellBar_LoadUI()

PlayerFrame:SetScale(1.15)
TargetFrame:SetScale(1.15)
FocusFrame:SetScale(1.15)
TargetFrameSpellBar:SetScale(1.58)
FocusFrameSpellBar:ClearAllPoints();FocusFrameSpellBar:SetPoint(“CENTER”, UIParent, “CENTER”, -100, -110);FocusFrameSpellBar.SetPoint = function() end
local b=HonorWatchBar b:UnregisterAllEvents() b:Hide() b.Show=b.Hide
TargetFrameSpellBar:ClearAllPoints();TargetFrameSpellBar:SetPoint(“CENTER”, UIParent, “CENTER”, -125, 110);TargetFrameSpellBar.SetPoint = function() end
FocusFrameSpellBar:SetScale(1.58)
local b=ArtifactWatchBar b:UnregisterAllEvents() b:Hide() b.Show=b.Hide
SetCVar(“nameplateOccludedAlphaMult”,1)
function Movebuff() BuffFrame:ClearAllPoints() BuffFrame:SetScale(1.1) BuffFrame:SetPoint(“CENTER”,PlayerFrame,“CENTER”,700,80) end hooksecurefunc(“UIParent_UpdateTopFramePositions”,Movebuff) Movebuff()
StanceButton1:ClearAllPoints()
StanceButton1:SetPoint(“CENTER”,-6000,0)
StanceButton1.SetPoint = function() end

here is the rest of the code, is there a problem when trying to load multiple UI elements at once?

Things like PlayerFrame are always available, so that’s not it. You can eliminate those lines at the top

Now that I can see your code, I think you might have an issue with these two lines.

local b=HonorWatchBar b:UnregisterAllEvents() b:Hide() b.Show=b.Hide

local b=ArtifactWatchBar b:UnregisterAllEvents() b:Hide() b.Show=b.Hide

These bars were eliminated circa 8.1, replaced with a new StatusTrackingBarManager. Here is replacement code, along with placeholders for reputation, experience and azerite bars if you want to control them as well.

MainMenuBar:HookScript("OnEvent", function(self, event, arg1, arg2)
    if event == "PLAYER_ENTERING_WORLD" and (arg1 or arg2) then
        local mgr = StatusTrackingBarManager
        local rep, hon, art, exp, az = mgr.bars[1], mgr.bars[2], mgr.bars[3], mgr.bars[4], mgr.bars[5]
        
        function hon:ShouldBeVisible() return false end
        function art:ShouldBeVisible() return false end
        
        mgr:UpdateBarsShown()
    end
end)
1 Like

It could be the forums playing tricks, but the quotation marks were not formatted properly when I copied them to a code editor. Just in case that is affecting you, here is the whole thing in code format ( ``` followed by a line break on the forums)

PlayerFrame:SetScale(1.15)
TargetFrame:SetScale(1.15)
FocusFrame:SetScale(1.15)

FocusFrameSpellBar:ClearAllPoints();
FocusFrameSpellBar:SetPoint("CENTER", UIParent, "CENTER", -100, -110);
FocusFrameSpellBar.SetPoint = function() end
FocusFrameSpellBar:SetScale(1.58)

TargetFrameSpellBar:ClearAllPoints();
TargetFrameSpellBar:SetPoint("CENTER", UIParent, "CENTER", -125, 110);
TargetFrameSpellBar.SetPoint = function() end
TargetFrameSpellBar:SetScale(1.58)

function Movebuff()
	BuffFrame:ClearAllPoints() BuffFrame:SetScale(1.1) BuffFrame:SetPoint("CENTER",PlayerFrame,"CENTER",700,80)
end 
hooksecurefunc("UIParent_UpdateTopFramePositions",Movebuff)
Movebuff()

StanceButton1:ClearAllPoints()
StanceButton1:SetPoint("CENTER",-6000,0)
StanceButton1.SetPoint = function() end

MainMenuBar:HookScript("OnEvent", function(self, event, arg1, arg2)
    if event == "PLAYER_ENTERING_WORLD" and (arg1 or arg2) then
        local mgr = StatusTrackingBarManager
        local rep, hon, art, exp, az = mgr.bars[1], mgr.bars[2], mgr.bars[3], mgr.bars[4], mgr.bars[5]
        
        function hon:ShouldBeVisible() return false end
        function art:ShouldBeVisible() return false end
        
        mgr:UpdateBarsShown()
    end
end)

SetCVar("nameplateOccludedAlphaMult", 1)
1 Like

Ha, thank you very much, this worked! Also very informative, I learned a lot.