Originally Posted by Vrul
I didn't pay enough attention to notice the shaman line has it's true/false assignments reversed compared to the others.
Try your code on a druid, monk, or paladin caster; or a melee shaman, and see if it works. The only reason it works now is because when GetSpecialization() returns nil the default fall through value is what you wanted anyway (for the classes you tested).
|
Tried it out on a caster Druid and you are correct, it returns false rather than nil though. Looking at it now it just dawned on me that the reason it works for a Shaman is as you say, it falls back on true for Shamans and false for Druids because
spec returns nil.
I'm going to try waiting for PLAYER_LOGIN to fire and see if that helps me.
Originally Posted by Vrul
Also, the code I posted should be changed to:
Code:
local isCaster
local cbCheck = function()
if playerClass == 'DRUID' then
isCaster = (GetSpecialization() or 0) % 3 == 1
elseif playerClass == 'MONK' then
isCaster = GetSpecialization() == 2
elseif playerClass == 'PALADIN' then
isCaster = GetSpecialization() == 1
elseif playerClass == 'SHAMAN' then
isCaster = GetSpecialization() ~= 2
else
isCaster = playerClass == 'MAGE' or playerClass == 'PRIEST' or playerClass == 'WARLOCK'
end
end
|
Thanks a bunch for this!
Originally Posted by Vrul
You will also have an issue with a druid, monk, paladin, or shaman who changes spec from caster to non-caster (or vice versa). They will need to /reload for the castbar to update as the code stands now.
|
This I know, I was trying to get around that by listening for the PLAYER_SPECIALIZATION_CHANGED event but it wouldn't have worked that way anyway I'm fairly sure. I simply don't know how to make it change without a reload, so it's a limitation I'll live with. I'm not planning to make this layout available to the public anyway.
EDIT: Back to where it doesn't work on reload but seems to work on a fresh login now. Code here:
https://gist.github.com/ShredL/1ebcc6b803a0aaab86ea
isCaster check on line 192, castbar creation at line 277. It prints isCaster correctly now, just doesn't spawn a castbar after reloading and I don't know why.