Reference › Function reference › Platform

Platform.roster_class.GetRosterClassObservation

public

Call as

addon.Platform:GetRosterClassObservation(unit)

Available directly through addon; no dependency is needed.

What it does

Read public roster identity on identified client families. Input routing is limited to player, party1 through party4 and raid1 through raid40. Call UnitExists with that exact one-argument token first; known false returns false without querying class. For a present unit, consume only UnitClass return two as a readable nonempty class filename string, without a class enum restriction. Missing, failed, malformed or restricted required facts return nil with a reason.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).
unitstringExact helper-owned player, party1..party4 or raid1..raid40 token.

Returns

1string | boolean | nilObserved class filename string, false for a known absent unit, or nil when unavailable.
2string | nilValidation, policy or availability reason for a nil result.

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
UnitClassClassic 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

for index = 1, 4 do
  local class = addon.Platform:GetRosterClassObservation("party" .. index)
  if class == "PRIEST" then return true end
end
return false

Dependencies

Source

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

Platform.roster_class.GetRosterClassObservation(self, unit)
    if not self:CanReadValue(unit) then return nil,'restricted-value' end
    if type(unit)~='string' or not rosterUnit(unit) then return nil,'invalid-roster-unit' end
    if self:GetClientFamily()=='unknown' then return nil,'unsupported-client' end
    if type(UnitExists)~='function' then return nil,'missing-api' end
    local ok,exists=pcall(UnitExists,unit)
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(exists) then return nil,'restricted-value' end
    if exists==nil then return nil,'roster-data-unavailable' end
    if type(exists)~='boolean' then return nil,'invalid-api-result' end
    if not exists then return false end
    if type(UnitClass)~='function' then return nil,'missing-api' end
    local success,_,class=pcall(UnitClass,unit)
    if not success then return nil,'api-error' end
    if not self:CanReadValue(class) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(class) then return nil,'restricted-value' end
    if class==nil then return nil,'roster-class-unavailable' end
    if type(class)~='string' or class=='' then return nil,'invalid-api-result' end
    return class

Back to Function reference