Hey guys, I noticed a small bug in my code that I overlooked before. So basically the highlighted code is suppose to print a chat message telling the player their current "loot spec chosen". When you right click portrait > loot specialization There are 4 options, lets say the warrior for example:
- Current Specialization (Protection)
Arms
Fury
Protection
When you choose anything other than "Current Specialization" The print works just fine, naming your set loot spec chosen, but if Current Specialization is selected, returns a nil in the chat print.
Question, can anyone point out my obvious mistake? I must have deleted something that I needed before to correct this, unless something changed in 6.1, or I missed an option?
Code:
local isInstance = IsInInstance() -- Check if Player is In an Instance
if event == "PLAYER_ENTERING_WORLD" and isInstance then -- "and isInstance" Remove this before 'then' to test code without being in LFG instance
local currentSpec = GetSpecialization()
local currentSpecName = currentSpec and select(2, GetSpecializationInfo(currentSpec)) or "None" -- Get Current Spec Name
local role = UnitGroupRolesAssigned("player"); -- Role selected or assigned in LFG
local spec = GetSpecialization()
local specRole = GetSpecializationRole(spec) -- Current Role Specialization
if role ~= specRole then
local specId = GetSpecialization() -- Loot Role Info
local spId = GetLootSpecialization() -- Loot Role Info
local sId, spName = GetSpecializationInfoByID(spId) -- Loot Role Info
StaticPopup_Show ("WRONG_SPEC_WARNING") -- Show Static PopUp from below
playSound() -- Illidan Sound File
print("|cffffff00--- SpecCheck Addon Warning: Wrong Role Active")
print("|cff00ccff--- Active Specialization:|r ", currentSpecName)
print("|cff00ccff--- Loot Specialization: |r", spName)
Thanks for any help and taking the time to look,
Krai