Reference › Function reference › Platform

Platform.role.GetInspectRoleObservation

public

Call as

addon.Platform:GetInspectRoleObservation(unit)

Available directly through addon; no dependency is needed.

What it does

Observe a selected unit role on probe- and restricted-policy clients without issuing inspection requests. Known unit absence returns false. Prefer the callable modern inspection API, with legacy fallback only when that callable is absent; a selected failure never falls through. Require a positive finite integral specialization ID and consume only role return five from the exact one-argument GetSpecializationInfoByID call. Missing, failed, restricted or malformed required facts are unavailable; readable nonempty future role strings remain exact.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).
unitstringSelected nonempty unit token; unchanged native argument.

Returns

1string | boolean | nilKnown nonempty role string, false for known absent unit, or nil when unavailable.
2string | nilPolicy, capability or required-observation availability reason.

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

  • Not available on that edition (the reason is in the tooltip)
  • Only while Blizzard's deprecation fallbacks are on
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
C_SpecializationInfoClassic EraTBC AnniversaryClassic progressionForeverRetail
GetInspectSpecializationClassic EraTBC AnniversaryClassic progressionForeverRetail
GetSpecializationInfoByIDClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic progressionForeverRetail
canaccessvalueClassic EraTBC AnniversaryClassic progressionForeverRetail

Secret values (Retail and Forever)

On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.

Example

local role = addon.Platform:GetInspectRoleObservation("target")
if role == nil then return nil end
return role == "HEALER"

Dependencies

Source

Platform/role.lua, line 50. Read only in game; Duplicate makes an editable copy.

Platform.role.GetInspectRoleObservation(self, unit)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not self:CanReadValue(unit) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if type(UnitExists)~='function' then return nil,'missing-api' end
    local existsOk,exists=pcall(UnitExists,unit)
    if not existsOk then return nil,'api-error' end
    if not self:CanReadValue(exists) then return nil,'restricted-value' end
    if exists==nil then return nil,'unit-data-unavailable' end
    if type(exists)~='boolean' then return nil,'invalid-api-result' end
    if not exists then return false end
    local namespace,reason=readField(self,_G,'C_SpecializationInfo')
    if reason then return nil,reason end
    local inspect
    if namespace~=nil then
        inspect,reason=readField(self,namespace,'GetInspectSpecialization')
        if reason then return nil,reason end
    end
    if type(inspect)~='function' then
        inspect,reason=readField(self,_G,'GetInspectSpecialization')
        if reason then return nil,reason end
    end
    if type(inspect)~='function' then return nil,'missing-api' end
    local ok,spec=pcall(inspect,unit)
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(spec) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(spec) then return nil,'restricted-value' end
    if spec==nil or spec==0 then return nil,'specialization-unavailable' end
    if type(spec)~='number' or spec~=spec or spec>=math.huge or spec<=0 or spec%1~=0 then return nil,'invalid-api-result' end
    local metadata
    metadata,reason=readField(self,_G,'GetSpecializationInfoByID')
    if reason then return nil,reason end
    if type(metadata)~='function' then return nil,'missing-api' end
    local roleOk,role=pcall(function() return (select(5,metadata(spec))) end)
    if not roleOk then return nil,'api-error' end
    return roleValue(self,role)

Back to Function reference