WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Lua, Help with Event for moving BuffFrame (https://www.wowinterface.com/forums/showthread.php?t=57806)

tilik09 02-04-20 06:49 AM

Lua, Help with Event for moving BuffFrame
 
Hello Guys,

I am new to lua scripting, and I have a problem with RegisterEvent.
I was running a custom addon usually just to hide stuff like error speach or player text healing
ex: UIErrorsFrame:Hide()
This commands where executed on Frame:RegisterEvent("PLAYER_LOGIN") and was working ok.

Now I took it a step further and wanted to play a bit with the Buff, Debuff Frames to move an anchor them as I please.
The problem is that Frame:RegisterEvent("PLAYER_LOGIN") does not work for moving the BuffFrame.

From my understanding, it seems like my addon loads and executes the code before the Default Blizzard Action that handles the de buff positioning.

For testing, I tried to use "CHAT_MSG_YELL" and "UNIT_AURA" events. And it seems it is working as intended. When I type in chat "/y test" the addon fires and adjusts the positioning of the frame.
Same when I receive a new aura (Power world shield for example).

Is there a way, to simply execute my positioning commands just Once and not everytime I get a new aura?
(Similar behavior as Player_Login which executes commands /console reloadui)

Code:

local Frame = CreateFrame("Frame")
Frame:RegisterEvent("PLAYER_LOGIN")
Frame:RegisterEvent("CHAT_MSG_YELL")
Frame:RegisterEvent("UNIT_AURA")

--Frame:SetScript("OnEvent", function(self, event, ...)


Frame:SetScript("OnEvent", function(...)
        --Your hiding code goes between this line


        minimapSortButtons();
        playerBuffs();

        --And this one
end)


function minimapSortButtons()
        UIErrorsFrame:Hide();
        print ("function");
        print ("Test1");
end

function playerBuffs()
        local pb = BuffFrame:GetName();       
        BuffFrame:Show();
        BuffFrame:ClearAllPoints();
        BuffFrame:SetPoint("TOPRIGHT",MinimapCluster,"TOPLEFT",-5,-5);
        --BuffFrame:SetUserPlaced(true);
        print("test2");
        print("Argh, stop with the yelling!");

end



All times are GMT -6. The time now is 11:45 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI