Thread: Nameplates
View Single Post
07-26-12, 05:14 PM   #11
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by zork View Post
NamePlate1 is not found. Script stops.
NamePlateIds start at 2xx in my case. Not sure why...it's just what the GetName() spits out.
The reason is because you did /reloads, and the game keeps continuing from where it left off before you did.
Unlike most frames, the nameplates are written (or wrapped) in C, and will not reload like the rest of the UI does.

Here is a way to counter this:
Lua Code:
  1. local function Update(self)
  2.     -- do whatever
  3. end
  4.  
  5. local index = 1
  6. local fresh = true
  7.  
  8. local addon = CreateFrame('Frame')
  9. addon:SetScript('OnUpdate', function()
  10.     while _G['NamePlate' .. index] or fresh do
  11.         local frame = _G['NamePlate' .. index]
  12.         if(frame) then
  13.             fresh = false
  14.  
  15.             frame:HookScript('OnShow', Update)
  16.  
  17.             Update(frame)
  18.         end
  19.  
  20.         index = index + 1
  21.     end
  22. end)
  23. addon:Show()

Last edited by p3lim : 07-26-12 at 05:23 PM.