View Single Post
08-24-14, 07:24 AM   #2
Malakahh
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jun 2009
Posts: 30
Some of your if statements are a bit odd to say the least, as they will always be true. The ones I'm talking about are lines 6, 8, and 32 of the first block of code you posted. Try changing it to

Lua Code:
  1. -- Doesn't seem to change the value of my isCaster variable
  2. local spec = GetSpecialization()
  3. local _, playerClass = UnitClass("PLAYER")
  4. local isCaster
  5. local function cbCheck()
  6.     if playerClass == 'DRUID' or playerClass == 'MONK' or playerClass == 'PALADIN' or playerClass == 'SHAMAN' then
  7.         if playerClass == 'DRUID' then
  8.             if spec == 1 or spec == 4 then
  9.                 isCaster = true
  10.             else
  11.                 isCaster = false
  12.             end
  13.         elseif playerClass == 'MONK' then
  14.             if spec == 2 then
  15.                 isCaster = true
  16.             else
  17.                 isCaster = false
  18.             end
  19.         elseif playerClass == 'PALADIN' then
  20.             if spec == 1 then
  21.                 isCaster = true
  22.             else
  23.                 isCaster = false
  24.             end
  25.         elseif playerClass == 'SHAMAN' then
  26.             if spec == 2 then
  27.                 isCaster = false
  28.             else
  29.                 isCaster = true
  30.             end
  31.         end
  32.     elseif playerClass == 'DEATHKNIGHT' or playerClass == 'HUNTER' or playerClass == 'ROGUE' or playerClass == 'WARRIOR' then
  33.         isCaster = false
  34.     else
  35.         isCaster = true
  36.     end
  37. end
  38. local cbCheckFrame = CreateFrame("Frame")
  39. cbCheckFrame:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
  40. cbCheckFrame:RegisterEvent('PLAYER_ENTERING_WORLD')
  41. cbCheckFrame:RegisterEvent('PLAYER_LOGIN')
  42. cbCheckFrame:SetScript("OnEvent", function()
  43.     cbCheck()
  44. end)
  Reply With Quote