Call as
addon.Platform:GetUnitPowerObservation(unit, resource, includeMaximum)
Available directly through addon; no dependency is needed.
What it does
Observe explicit mana or the current raw power resource on supported readable clients. Select resource identities from the live PowerType enum; explicit mana never falls back to the current bar. Known absence returns exists=false; missing, failed, restricted or malformed observations return nil with a reason. Current-mode quantities preserve signed native resources; explicit mana is nonnegative. Request maximum only when needed; percentage consumers must require a positive maximum.
Arguments
| Name | Type | What it does |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (implicit with colon calls). |
unit | string | Exact unit token whose resource should be observed; this does not redirect player or vehicle units. |
resource | string | mana selects the explicit live Mana enum; current reads and forwards the actual UnitPowerType identity, including Mana zero. |
includeMaximum | boolean | nil | True also observes the selected resource maximum; false or nil reads current quantity only. |
Returns
| 1 | table | nil | Fresh readable record with exists and, when present, powerType and finite current quantity. Requested maximum is finite and nonnegative. Quantities may be fractional; current-mode current may be signed. |
|---|---|---|
| 2 | string | nil | Policy, query-validation or availability reason for a nil resource 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 power = addon.Platform:GetUnitPowerObservation("player", "mana", true)
if not power or not power.exists or not power.maximum then return nil end
if power.maximum <= 0 then return nil end
return power.current / power.maximum < 0.3Dependencies
finite→Platform.unit_power.finite
Source
Platform/unit_power.lua, line 31. Read only in game; Duplicate makes an editable copy.
Platform.unit_power.GetUnitPowerObservation(self, unit, resource, includeMaximum)
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(resource) or not self:CanReadValue(includeMaximum) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if resource~='mana' and resource~='current' then return nil,'invalid-power-query' end
if includeMaximum~=nil and type(includeMaximum)~='boolean' then return nil,'invalid-power-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
if not self:CanReadValue(Enum) then return nil,'restricted-value' end
if type(Enum)~='table' then return nil,'power-type-unavailable' end
local types=Enum.PowerType
if not self:CanReadValue(types) then return nil,'restricted-value' end
if type(types)~='table' then return nil,'power-type-unavailable' end
local powerType
if resource=='mana' then
powerType=types.Mana
else
if type(UnitPowerType)~='function' then return nil,'missing-api' end
local ok
ok,powerType=pcall(UnitPowerType,unit)
if not ok then return nil,'api-error' end
end
if not self:CanReadValue(powerType) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(powerType) then return nil,'restricted-value' end
if powerType==nil then return nil,'power-type-unavailable' end
if not finite(powerType) or powerType<0 or powerType%1~=0 then return nil,'invalid-api-result' end
local known=false
for _,id in pairs(types) do
if self:CanReadValue(id) and type(id)=='number' and id==powerType then known=true;break end
end
if not known then return nil,'power-type-unavailable' end
if type(UnitPower)~='function' then return nil,'missing-api' end
local currentOk,current=pcall(UnitPower,unit,powerType)
if not currentOk then return nil,'api-error' end
if not self:CanReadValue(current) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(current) then return nil,'restricted-value' end
if current==nil then return nil,'power-data-unavailable' end
if not finite(current) or resource=='mana' and current<0 then return nil,'invalid-api-result' end
local record={exists=true,powerType=powerType,current=current}
if includeMaximum then
if type(UnitPowerMax)~='function' then return nil,'missing-api' end
local maximumOk,maximum=pcall(UnitPowerMax,unit,powerType)
if not maximumOk then return nil,'api-error' end
if not self:CanReadValue(maximum) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(maximum) then return nil,'restricted-value' end
if maximum==nil then return nil,'power-data-unavailable' end
if not finite(maximum) or maximum<0 then return nil,'invalid-api-result' end
record.maximum=maximum
end
return record




