View Single Post
02-24-15, 04:21 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by SDPhantom View Post
local _,class,id=UnitClass("Player");
Technically speaking, "Player" is not a valid unit token; even though the game will auto-correct to "player" for you, it's best to be in the habit of using the correct capitalization.

Originally Posted by SDPhantom View Post
if class=="PRIEST" then return; end
I'd suggest additionally disabling the addon if the player isn't a priest; it's not like the same character who isn't a priest today will suddenly become one tomorrow.

Code:
local ADDON_NAME = ...
if select(2, UnitClass("player")) ~= "PRIEST" then return DisableAddOn(ADDON_NAME) end
Originally Posted by SDPhantom View Post
PS: I don't know if glyph data is available immediately at login or if you need to wait for PLAYER_LOGIN to fire. You should still load even if you don't detect the glyph initially as glyphs can be changed by the player while logged in. Perhaps put the addon into a sleep state until it sees the glyph by login, spec change, or glyph swap.
Glyph information almost certainly falls into the same category other similar types of information -- it's available immediately after reloading the UI, but not on a fresh login. Instead of registering for other events in PLAYER_LOGIN, register for GLYPH_ADDED and GLYPH_REMOVED. When one of those fires, check for the glyph, and then register or unregister all the other events based on whether it's found or not. You'd probably also want to hide any currently-shown frames when the glyph is removed.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote