Call as
addon.Platform:GetUnitStatObservation(unit, stat)
Available directly through addon; no dependency is needed.
What it does
Observe the effective statistic from native return two only. On probe- and restricted-policy clients, query exact UnitExists(unit), then UnitStat(unit,stat) for selector 1..5 or UnitArmor(unit) for selector 6. Known absence returns exists=false; missing, failed, restricted or nonfinite required facts return nil. Preserve finite signed, fractional and zero values; ignore all unused tuple fields. The 1..6 route is an RM selector policy, not a native value-domain limit.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Selected nonempty unit token, unchanged in native calls. |
stat | number | Integral RM statistic selector 1..5, or 6 for effective armor. |
Returns
| 1 | table | nil | Record with exists=false, or exists=true and finite value; nil when unavailable. |
|---|---|---|
| 2 | string | nil | Query, policy or 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 API | |||||
|---|---|---|---|---|---|
UnitArmor | |||||
UnitExists | |||||
UnitStat | |||||
canaccessvalue |
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 armor = addon.Platform:GetUnitStatObservation("player", 6)
if not armor or not armor.exists then return nil end
return armor.value >= 10000Dependencies
finite→Platform.unit_stat.finite
Source
Platform/unit_stat.lua, line 27. Read only in game; Duplicate makes an editable copy.
Platform.unit_stat.GetUnitStatObservation(self, unit, stat)
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(stat) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if not finite(stat) or stat%1~=0 or stat<1 or stat>6 then return nil,'invalid-stat-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 {exists=false} end
local fn
if stat==6 then fn=UnitArmor else fn=UnitStat end
if type(fn)~='function' then return nil,'missing-api' end
local ok,_,effective
if stat==6 then ok,_,effective=pcall(fn,unit)
else ok,_,effective=pcall(fn,unit,stat) end
if not ok then return nil,'api-error' end
if not self:CanReadValue(effective) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(effective) then return nil,'restricted-value' end
if effective==nil then return nil,'stat-data-unavailable' end
if not finite(effective) then return nil,'invalid-api-result' end
return {exists=true,value=effective}




