Thread: Nameplates
View Single Post
07-26-12, 08:11 PM   #18
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Here we go, PLAYER_LOGOUT event saving the last index to a savedvariable, two OnUpdate scripts iterating either a new index or the savedvariable, and either of them shuts down the savedvariable one.

Lua Code:
  1. local index = 1
  2.  
  3. local backup = CreateFrame'Frame'
  4. backup:SetScript('OnUpdate', function(self)
  5.     if(not SomeCleverVariableName) then return end
  6.  
  7.     if(_G['NamePlate' .. SomeCleverVariableName]) then
  8.         self:Hide()
  9.  
  10.         index = SomeCleverVariableName
  11.         SomeCleverVariableName = nil
  12.     end
  13. end)
  14.  
  15. local iterate = CreateFrame'Frame'
  16. iterate:SetScript('OnUpdate', function()
  17.     while(_G['NamePlate' .. index]) do
  18.         local frame = _G['NamePlate' .. index]
  19.         frame:HookScript('OnShow', Update)
  20.         backup:Hide()
  21.  
  22.         Update(frame)
  23.  
  24.         index = index + 1
  25.     end
  26. end)
  27.  
  28. iterate:RegisterEvent'PLAYER_LOGOUT'
  29. iterate:SetScript('OnEvent', function()
  30.     SomeCleverVariableName = index + 1
  31. end)

Last edited by p3lim : 07-26-12 at 09:42 PM.