Thread Tools Display Modes
Prev Previous Post   Next Post Next
03-13-11, 03:23 PM   #1
DrGlenn
A Kobold Labourer
 
DrGlenn's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 1
Hooking into OnUpdate for moving unitframes

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
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Hooking into OnUpdate for moving unitframes


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off