Reference › Function reference › Platform

Platform.health_forecast.GetHealthForecastProviderObservation

public

Call as

addon.Platform:GetHealthForecastProviderObservation(unit)

Available directly through addon; no dependency is needed.

What it does

Read optional RealMobHealth using its exact one-argument dot call. Absent nil/false namespace returns an empty record. Normalize current and maximum independently: nil/false fields permit native fallback, numeric zero remains present. Malformed, failed, restricted, negative or nonfinite consumed provider facts are unavailable. No provider or stale fallback cache is used.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (implicit with colon calls).
unitstringSelected unit token forwarded as the only provider argument.

Returns

1table | nilPartial current/maximum record, empty when provider absent, or nil when unavailable.
2string | nilProvider, validation 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.

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.

Example

local record = addon.Platform:GetHealthForecastProviderObservation("target")
if not record or not record.current or not record.maximum then return nil end
if record.maximum == 0 then return nil end
return record.current / record.maximum < 0.2

Dependencies

Source

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

Platform.health_forecast.GetHealthForecastProviderObservation(self, unit)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not self:CanReadValue(unit) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    local provider=_G.RealMobHealth
    if not self:CanReadValue(provider) then return nil,'restricted-value' end
    if provider==nil or provider==false then return {} end
    local api,why=readField(self,provider,'GetUnitHealth')
    if why then return nil,why end
    if type(api)~='function' then return nil,'missing-api' end
    local ok,current,maximum=pcall(api,unit)
    if not ok then return nil,'api-error' end
    local value,reason=providerValue(self,current)
    if reason then return nil,reason end
    local max,maxReason=providerValue(self,maximum)
    if maxReason then return nil,maxReason end
    return {current=value,maximum=max}

Back to Function reference