With the talent reset I haven't updated most of my characterss (and the Era PTR isn't available) so this is just what I would have done first.
Changed:
Lua Code:
local playerRole = LibClassicSpecs.Role
to:
Lua Code:
local playerRole, specIndex
And then in the PLAYER_ENTERING_WORLD event, added:
Lua Code:
if not playerRole then
specIndex = GetSpecialization()
playerRole = select(6, GetSpecializationInfo(specIndex))
print("playerRole", playerRole, specIndex) -- What did we get?
end
That
should get you a playerRole of "TANK", "HEALER", "DAMAGER" at login.
Then you could use:
Lua Code:
if playerRole == nil then
--xxx Text:SetText(hexa.."No Stats"..hexb)
else
if playerRole == "TANK" then
UpdateTank(self)
elseif playerRole == "HEALER" then
UpdateCaster(self)
elseif playerRole == "DAMAGER" then
UpdateDamager(self)
end
end
You would need to handle updating when changing/adding talents during a session.
I would probably do most/all class, spec. etc. initialisation at PLAYER_LOGIN or the initial PLAYER_ENTERING_WORLD rather than just as your addon is loaded as it gives the game some time to know more about you current character.