Reference › Function reference › Platform

Platform.points.GetUnitPointFragmentObservation

public

Call as

addon.Platform:GetUnitPointFragmentObservation(unit, powerType, kind)

Available directly through addon; no dependency is needed.

What it does

Observe a point resource that the client reports in fragments (Mists of Pandaria Burning Embers). Current uses exactly UnitPower(unit,powerType,true) and maximum UnitPowerMax(unit,powerType,true); the result is divided by Blizzard MAX_POWER_PER_EMBER (10), so 35 fragments are 3.5. Probe policy only. Missing, failed, restricted or malformed data remains unavailable; it never falls back to the whole-unit query. No cache is added.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).
unitstringExact nonempty unit token, passed unchanged.
powerTypenumberExplicit readable finite nonnegative integer power selector.
kindstringExactly current for UnitPower or maximum for UnitPowerMax.

Returns

1number | nilFinite quantity in whole units with its fractional part; nil when unavailable.
2string | nilPolicy, query-validation or required observation availability reason for a nil quantity.

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
UnitPowerClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitPowerMaxClassic 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

local embers = Enum.PowerType.BurningEmbers
if not embers then return nil end
local current = addon.Platform:GetUnitPointFragmentObservation("player", embers, "current")
if current == nil then return nil end
return current >= 3.5

Dependencies

Source

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

Platform.points.GetUnitPointFragmentObservation(self, unit, powerType, kind)
    if self:GetCombatDataPolicy()~='probe' then return nil,'unsupported-policy' end
    if not self:CanReadValue(unit) or not self:CanReadValue(powerType) or not self:CanReadValue(kind) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if type(powerType)~='number' or powerType~=powerType or powerType<0 or powerType==math.huge or powerType%1~=0 then return nil,'invalid-point-power-query' end
    if kind~='current' and kind~='maximum' then return nil,'invalid-point-power-query' end
    local api
    if kind=='current' then api=UnitPower else api=UnitPowerMax end
    if type(api)~='function' then return nil,'missing-api' end
    local ok,result=pcall(api,unit,powerType,true)
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(result) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(result) then return nil,'restricted-value' end
    if result==nil then return nil,'point-power-unavailable' end
    if type(result)~='number' or result~=result or result==math.huge or result==-math.huge then return nil,'invalid-api-result' end
    return result/pointFragmentsPerWhole

Back to Function reference