I've been fiddling with a very basic UI modification where I need to scale and move the default unitframes.
I initially just made a macro for re-scaling and re-positioning the unitframes, but wanted something more permanent to avoid having to run the macro after each loading screen. I tried using a wide variety of "move anything"-addons out there, but they all had issues with vehicle unitframes.
I tried to come up with my own solution, and ended up with the following bit of code, which actually works even with vehicle unitframes:
Code:
local timer = 2
local f = CreateFrame("Frame")
f:SetScript("OnUpdate", function(self, elapsed)
timer = timer - elapsed
if (timer > 0) then return end
PlayerFrame:SetScale(1.1)
PetFrame:SetScale(1.1)
FocusFrame:SetScale(1.1)
TargetFrame:SetScale(1.1)
PlayerFrame:ClearAllPoints()
PlayerFrame:SetPoint("CENTER", -250, -150)
TargetFrame:ClearAllPoints()
TargetFrame:SetPoint("CENTER", 250, -150)
FocusFrame:ClearAllPoints()
FocusFrame:SetPoint("CENTER", -500, -150)
timer = timer + 2 -- or just timer = 5 if you don't need to be super exact
end)
My question is: would this be considered bad programming practice, considering the way I'm hooking into OnUpdate ? This is pretty much my first time working with LUA for WoW, so I'm worried that the code could be a resource-hog