Llamar como
addon.Platform:GetHealthForecastValueObservation(unit, kind)
Disponible directamente a través de addon; no hace falta ninguna dependencia.
Qué hace
Lee un valor escalar de salud diferido tras una comprobación de identidad aparte. El tipo current usa exactamente UnitHealth(unit); maximum usa exactamente UnitHealthMax(unit). Los clientes con política de sondeo o restringida aceptan números finitos legibles no negativos, incluido cero. No se añade ninguna llamada repetida de existencia/GUID ni alternativa de tupla.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
self | RMPlatform | Adaptador de plataforma de Rotation Master (implícito en las llamadas con dos puntos). |
unit | string | Token de unidad seleccionado no vacío; esta llamada por sí sola no establece la presencia. |
kind | string | Tipo escalar cerrado: current o maximum. |
Retornos
| 1 | number | nil | Valor escalar de salud nativo finito y no negativo, o nil si no está disponible. |
|---|---|---|
| 2 | string | nil | Motivo de disponibilidad de la política, la validación o una observación necesaria. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.
- No disponible en esa edición (el motivo aparece en la información emergente)
- Solo mientras estén activas las alternativas de Blizzard para API obsoletas
| API del juego | |||||
|---|---|---|---|---|---|
UnitHealth | |||||
UnitHealthMax | |||||
canaccessvalue |
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Ejemplo
local current = addon.Platform:GetHealthForecastValueObservation("target", "current")
local maximum = addon.Platform:GetHealthForecastValueObservation("target", "maximum")
if not current or not maximum or maximum == 0 then return nil end
return current / maximum <= 0.35Dependencias
finite→Platform.health_forecast.finite
Código fuente
Platform/health_forecast.lua, línea 81. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.health_forecast.GetHealthForecastValueObservation(self, unit, kind)
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(kind) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
local api
if kind=='current' then api=UnitHealth
elseif kind=='maximum' then api=UnitHealthMax
else return nil,'invalid-health-forecast-query' end
if type(api)~='function' then return nil,'missing-api' end
local ok,value=pcall(api,unit)
if not ok then return nil,'api-error' end
if not self:CanReadValue(value) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(value) then return nil,'restricted-value' end
if value==nil then return nil,'health-data-unavailable' end
if not finite(value) or value<0 then return nil,'invalid-api-result' end
return value




