Call as
addon.Platform:GetUnitMetadataObservation(unit, kind)
Available directly through addon; no dependency is needed.
What it does
Observe one consumed native unit metadata field after checking UnitExists: class uses UnitClass return two, creature uses the localized UnitCreatureType name, and classification uses UnitClassification. A readable absent unit returns false without querying metadata. Unused tuple fields do not affect availability; a required missing, failed, nil, restricted or malformed value returns nil with a reason. No player class, GUID, enum or translation inference is added.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Exact unit token checked for existence and passed to the selected metadata API. |
kind | string | One of class, creature or classification; other metadata kinds are unsupported. |
Returns
| 1 | string | boolean | nil | Readable consumed metadata string, false for a known absent unit, or nil when required data is unavailable. |
|---|---|---|
| 2 | string | nil | Policy, query-validation or availability reason for a nil metadata observation. |
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
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 classification = addon.Platform:GetUnitMetadataObservation("target", "classification")
if classification == nil then return nil end
return classification == "worldboss" or classification == "elite"Source
Platform/unit_metadata.lua, line 21. Read only in game; Duplicate makes an editable copy.
Platform.unit_metadata.GetUnitMetadataObservation(self, unit, kind)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if kind~='class' and kind~='creature' and kind~='classification' then return nil,'invalid-unit-metadata-query' 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 api
if kind=='class' then api=UnitClass
elseif kind=='creature' then api=UnitCreatureType
else api=UnitClassification end
if type(api)~='function' then return nil,'missing-api' end
local ok,observed
if kind=='class' then ok,observed=pcall(function() return select(2,api(unit)) end)
else ok,observed=pcall(api,unit) end
if not ok then return nil,'api-error' end
if not self:CanReadValue(observed) then return nil,'restricted-value' end
if observed==nil then return nil,'unit-metadata-unavailable' end
if type(observed)~='string' or observed=='' then return nil,'invalid-api-result' end
return observed




