I'm trying to make my oUF layout load different castbar settings depending on class and spec, and was planning on using a boolean for this but the variable I'm checking never seems to update it's value.
I get no errors, but I've added a debug print to see what isCaster returns and it always returns nil. I've tried this from multiple places in the code (inside the cbCheck function, inside the cbCheckFrame SetScript and inside the Shared function where I create the castbars) and the return is always nil.
This is where I try to change the value.
https://gist.github.com/ShredL/f00b576ae70456a971a8
Lua Code:
-- Doesn't seem to change the value of my isCaster variable
local spec = GetSpecialization()
local _, playerClass = UnitClass("PLAYER")
local isCaster
local function cbCheck()
if playerClass == 'DRUID' or 'MONK' or 'PALADIN' or 'SHAMAN' then
if playerClass == 'DRUID' then
if spec == 1 or 4 then
isCaster = true
else
isCaster = false
end
elseif playerClass == 'MONK' then
if spec == 2 then
isCaster = true
else
isCaster = false
end
elseif playerClass == 'PALADIN' then
if spec == 1 then
isCaster = true
else
isCaster = false
end
elseif playerClass == 'SHAMAN' then
if spec == 2 then
isCaster = false
else
isCaster = true
end
end
elseif playerClass == 'DEATHKNIGHT' or 'HUNTER' or 'ROGUE' or 'WARRIOR' then
isCaster = false
else
isCaster = true
end
end
local cbCheckFrame = CreateFrame("Frame")
cbCheckFrame:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
cbCheckFrame:RegisterEvent('PLAYER_ENTERING_WORLD')
cbCheckFrame:RegisterEvent('PLAYER_LOGIN')
cbCheckFrame:SetScript("OnEvent", function()
cbCheck()
end)
This is what is in my Shared function
https://gist.github.com/ShredL/8ee3b4978b3de4498c4c
Lua Code:
-- Castbar
if(unit=='player' or unit=='target') then
local Castbar = CreateFrame('StatusBar', nil, self)
local Spark = Castbar:CreateTexture(nil, 'OVERLAY')
if(unit=='player') then
if isCaster == false then
Castbar:SetAllPoints(Health)
Castbar:SetStatusBarTexture(statusBar)
Castbar:SetStatusBarColor(0, 0, 0, 0)
Castbar:SetFrameStrata('HIGH')
Spark:SetSize(2, 7)
Spark:SetTexture(1, 1, 1)
elseif isCaster == true then
Castbar:SetAllPoints(Health)
Castbar:SetStatusBarTexture(statusBar)
Castbar:SetStatusBarColor(0, 0, 0, 0)
Castbar:SetFrameStrata('HIGH')
Spark:SetSize(2, 7)
Spark:SetTexture(1, 1, 1)
end
else
Castbar:SetAllPoints(Health)
Castbar:SetStatusBarTexture(statusBar)
Castbar:SetStatusBarColor(0, 0, 0, 0)
Castbar:SetFrameStrata('HIGH')
Spark:SetSize(2, 20)
Spark:SetTexture(1, 1, 1)
end
self.Castbar = Castbar
Castbar.Spark = Spark
end
And here is the entire code if needed
https://gist.github.com/ShredL/59b138b727ca3a818299
It is probably something super simple that I'm overlooking, but I cannot seem to figure out how to change the value of isCaster. Any help is appreciated as always.