Thread: Nameplates
View Single Post
07-26-12, 02:25 PM   #7
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Dridzt View Post
That's a simple and clever workaround for the bug actually,
might have to poach it for a couple addons that I've had to keep disabled in beta.

Edit: Scratch that, a while loop won't work sadly, nameplate frames are reused for one so you don't always have a nice collection of sequential frames from 1 to n.
Even if we did have that, it would still need to wrap around to index 1 when it exits the while loop.
It's food for thought definitely...

Lua Code:
  1. local function Update(self)
  2.     -- do whatever
  3. end
  4.  
  5. local index = 1
  6.  
  7. local addon = CreateFrame('Frame')
  8. addon:SetScript('OnUpdate', function()
  9.     while _G['NamePlate' .. index] do
  10.         local frame = _G['NamePlate' .. index]
  11.         frame:HookScript('OnShow', Update)
  12.  
  13.         Update(frame)
  14.  
  15.         index = index + 1
  16.     end
  17. end)
  18. addon:Show()

Last edited by p3lim : 07-26-12 at 03:19 PM.