Thread: Nameplates
View Single Post
Unread 08-14-12, 01:53 AM   #32
villiv
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 14
really helpful thread. thank you for sharing this.

since all we like efficiency, do CVars-checking will help as well? or useless thoughts?

Lua Code:
  1. local f = CreateFrame('Frame')
  2. local a = f:CreateAnimationGroup()
  3. a:CreateAnimation():SetDuration(1/3)
  4. a:SetLooping('REPEAT')
  5. a:SetScript('OnLoop', function ()
  6.   -- LF Nameplates
  7. end)
  8.  
  9. local cvars = {
  10.     nameplateShowFriends = true, nameplateShowFriendlyPets = true, nameplateShowFriendlyGuardians = true, nameplateShowFriendlyTotems = true,
  11.     nameplateShowEnemies = true, nameplateShowEnemyPets = true, nameplateShowEnemyGuardians = true, nameplateShowEnemyTotems = true,
  12. }
  13.  
  14. local function check ()
  15.     for cvar in next, cvars do if ( GetCVarBool(cvar) ) then return a:Play() end end
  16.     return a:Stop()
  17. end
  18.  
  19. hooksecurefunc('SetCVar', function (cvar) if ( cvars[cvar] ) then return check() end end)

Last edited by villiv : 08-15-12 at 05:23 PM. Reason: the index should be handled LOGIN/OUT events
villiv is offline