This appears to be from the Vanilla Classic client. Wrath Classic adds buff consolidation and Dragon Flight's code was rewritten into mixins. The target client matters as oftentimes the code we're seeking to modify and sometimes even API calls will be different.
That being said, I have a few additional notes.
DEBUFF_ACTUAL_DISPLAY is being incremented as
DebuffButton_UpdateAnchors() is repeatedly called. For example, it would show zero in the first call, 1 for the second, 2 for the third, and so on. For this reason, you don't have a usable count of how many debuffs you have until after the last call of your function.
Screen doesn't refer to a UI Object. It isn't a magic keyword, Lua just sees it as a variable name. The contents of an undefined variable is
nil, which when given as the reference object for
:SetPoint() does anchor to the screen. The problem here is if anyone else were to haphazardly store a value into this variable, the result will break your code. It's common practice to anchor to
UIParent as that's the root frame of the entire UI and what UI scaling is applied directly to.
UIParent_ManageFramePositions() is called shortly after your function runs, which is susceptible to addon taint. You'll want to avoid directly replacing Blizzard functions unless you're sure protected code doesn't run after your function does. Blizzard provides a way to post-hook functions without spreading taint through
hooksecurefunc().
Here's how I would implement your requested change.
Lua Code:
local Step=BUFF_BUTTON_HEIGHT+5;-- Precalculated horizontal step
hooksecurefunc("BuffFrame_Update",function()
local offset=(DEBUFF_ACTUAL_DISPLAY-1)*Step/2;-- Half the total width added after the first debuff
for i=1,DEBUFF_ACTUAL_DISPLAY do
local debuff=_G["DebuffButton"..i];
if debuff and debuff:IsShown() then-- Sanity check
-- Arrange left-to-right (stock is right-to-left)
debuff:ClearAllPoints();-- Clear existing anchors (resizing happens when more than one point is defined)
debuff:SetPoint("CENTER",UIParent,"CENTER",(i-1)*Step-offset,-200);
end
end
end);