View Single Post
11-22-18, 09:25 AM   #13
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Vrul View Post
You can get rid of hard coding each class with:
Code:
--Check Player's Role

local playerRole
local function CheckRole()
    local specIndex = GetSpecialization()
    if specIndex then
        local _, _, _, _, _, role, priStat = GetSpecializationInfo(index)
        playerRole = role == "DAMAGER" and priStat == 4 and "CASTER" or role
    else
        playerRole = nil
    end
end

local eventHandler = CreateFrame("Frame")
eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
eventHandler:SetScript("OnEvent", CheckRole)
The Above code throws this error:
Code:
2x BasicUILite\Modules/Datatext.lua:185: Usage: GetSpecializationInfo(specIndex[, isInspect[, isPet[, inspectTarget[, sex]]]])
[C]: in function `GetSpecializationInfo'
BasicUILite\Modules/Datatext.lua:185: in function <BasicUILite\Modules/Datatext.lua:182>

Locals:
(*temporary) = nil

Originally Posted by Vrul View Post
by using
Code:
--Check Player's Role

local playerRole, isCaster
local function CheckRole()
    local specIndex = GetSpecialization()
    if specIndex then
        local _, priStat
        _, _, _, _, _, playerRole, priStat = GetSpecializationInfo(index)
        isCaster = priStat == 4
    else
        playerRole = nil
    end
end

local eventHandler = CreateFrame("Frame")
eventHandler:RegisterEvent("PLAYER_ENTERING_WORLD")
eventHandler:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
eventHandler:RegisterEvent("PLAYER_TALENT_UPDATE")
eventHandler:RegisterEvent("CHARACTER_POINTS_CHANGED")
eventHandler:SetScript("OnEvent", CheckRole)
The above code throws this error:
Code:
9x BasicUILite\Modules/Datatext.lua:188: Usage: GetSpecializationInfo(specIndex[, isInspect[, isPet[, inspectTarget[, sex]]]])
[C]: in function `GetSpecializationInfo'
BasicUILite\Modules/Datatext.lua:188: in function <BasicUILite\Modules/Datatext.lua:184>

Locals:
(*temporary) = nil
I would love to use one of these for less code in the coding but they seem not to work.

Thank You for trying.
Coke
  Reply With Quote