Call as
addon:GetConditionUnitLevel(unit, cache)
Available directly through addon; no dependency is needed.
What it does
Resolve a readable raw unit level for condition evaluation. Known absence returns false; unavailable observations return nil with a reason. Cache observations within the supplied evaluation pass. Only valid player levels are retained between passes until a skill, profile or level refresh.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMAddon | Rotation Master addon instance (implicit with colon calls). |
unit | string | Unit token whose raw level should be resolved. |
cache | table | nil | Shared evaluation cache; nil observes directly without a per-pass cache. |
Returns
| 1 | number | boolean | nil | Positive integer level, false for a known absent unit, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Availability or query-validation reason for a nil level. |
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.
It reads no game API directly.
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.
How the addon calls it
Source
Core/level_conditions.lua, line 21. Read only in game; Duplicate makes an editable copy.
Core.level_conditions.GetConditionUnitLevel(self, unit, cache)
if not self.Platform:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if self.Platform:GetClientFamily()=='unknown' then return nil,'unsupported-client' end
local longterm=self.longtermCache
if unit=='player' and type(longterm)=='table' then
local level=longterm.conditionPlayerLevel
if not self.Platform:CanReadValue(level) then return nil,'restricted-value' end
if level~=nil then
if type(level)~='number' or level~=level or level<=0 or level==math.huge or level%1~=0 then return nil,'invalid-api-result' end
return level
end
end
local record,reason=addon.Functions.cache.getCached(cache,self.Platform.GetUnitLevelObservation,self.Platform,unit)
if not record then return nil,reason end
if not record.exists then return false end
if unit=='player' and type(longterm)=='table' then longterm.conditionPlayerLevel=record.level end
return record.level