Thread: Nameplates
View Single Post
Unread 07-30-12, 02:51 PM   #21
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,391
In case anyone is interested. I took p3lims advise and changed my script. I'm now checking for nameplates like this:

Lua Code:
  1. --init
  2.   local _DB
  3.   local a = CreateFrame("Frame")
  4.   local index = 1
  5.   --timer  
  6.   local ag = a:CreateAnimationGroup()
  7.   ag.anim = ag:CreateAnimation()
  8.   ag.anim:SetDuration(0.33)
  9.   ag:SetLooping("REPEAT")
  10.   ag:SetScript("OnLoop", function(self, event, ...)
  11.     if _DB.namePlateIndex and _G["NamePlate".._DB.namePlateIndex] then
  12.       index = _DB.namePlateIndex
  13.       _DB.namePlateIndex = nil
  14.     end
  15.     while(_G["NamePlate" .. index]) do
  16.       local frame = _G['NamePlate' .. index]
  17.       if frame and not frame.rDB_styled then
  18.         styleNameplate(frame)
  19.       end
  20.       index = index + 1
  21.     end
  22.   end)
  23.   ag:Play()
  24.   --load some variable stuff
  25.   a:RegisterEvent("PLAYER_LOGIN")
  26.   a:RegisterEvent("PLAYER_LOGOUT")
  27.   a:SetScript("OnEvent", function(self,event,...)
  28.     if event == "PLAYER_LOGIN" then
  29.       _DB = _G["rDP_DB"] or {}
  30.       _G["rDP_DB"] = _DB
  31.     else
  32.       _DB.namePlateIndex = index + 0
  33.     end
  34.   end)

Sidenote...the index must not be increased by 1 on logout or one nameplate will not get styled. (Because the index is already increased by 1 once an index is found.

Running perfectly for now:
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 07-31-12 at 01:24 AM.
zork is offline