In case anyone is interested. I took p3lims advise and changed my script. I'm now checking for nameplates like this:
Lua Code:
--init
local _DB
local a = CreateFrame("Frame")
local index = 1
--timer
local ag = a:CreateAnimationGroup()
ag.anim = ag:CreateAnimation()
ag.anim:SetDuration(0.33)
ag:SetLooping("REPEAT")
ag:SetScript("OnLoop", function(self, event, ...)
if _DB.namePlateIndex and _G["NamePlate".._DB.namePlateIndex] then
index = _DB.namePlateIndex
_DB.namePlateIndex = nil
end
while(_G["NamePlate" .. index]) do
local frame = _G['NamePlate' .. index]
if frame and not frame.rDB_styled then
styleNameplate(frame)
end
index = index + 1
end
end)
ag:Play()
--load some variable stuff
a:RegisterEvent("PLAYER_LOGIN")
a:RegisterEvent("PLAYER_LOGOUT")
a:SetScript("OnEvent", function(self,event,...)
if event == "PLAYER_LOGIN" then
_DB = _G["rDP_DB"] or {}
_G["rDP_DB"] = _DB
else
_DB.namePlateIndex = index + 0
end
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: