Appel
Core.health_forecast_conditions.nativeValue(self, unit, kind, cache)
Enregistrez la dépendance Core.health_forecast_conditions.nativeValue, puis appelez-la sous ce nom. Un appel par espace de noms ne transmet pas self : utilisez un appel avec deux-points ou passez l'objet vous-même.
Ce qu'elle fait
Reads a unit's current or maximum health through the platform's health-forecast observer and the evaluation cache, rejecting restricted, missing, nonfinite or negative values.
Arguments
| Nom | Type | Ce qu'elle fait |
|---|---|---|
self | RMAddon | Rotation Master addon instance whose Platform is used. |
unit | string | Unit token to read. |
kind | string | "current" or "maximum". |
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
Retours
| 1 | number | nil | Health value, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, restricted-value, the observer's reason, health-data-unavailable or invalid-health-forecast-number. |
Éditions
Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.
Elle ne lit directement aucune API du jeu.
Valeurs secrètes (Retail et Forever)
Sur Retail et Forever, le jeu transmet aux addons des valeurs secrètes. Cette fonction utilitaire vérifie ce qu'elle lit (addon.Platform:CanReadValue) et renvoie nil avec une raison telle que restricted-value au lieu d'une valeur secrète qu'elle ne peut pas comparer. Traitez nil comme indisponible, pas comme false.
Comment l'addon l'appelle
Core.health_forecast_conditions.GetConditionHealthForecastif current==nil or current==false then current,why=nativeValue(self,unit,'current',cache);if current==nil then return nil,why end end
Dépendances
Source
Core/health_forecast_conditions.lua, ligne 52. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
Core.health_forecast_conditions.nativeValue(self, unit, kind, cache)
local platform=self.Platform
if type(platform.GetHealthForecastValueObservation)~='function' then return nil,'missing-api' end
local value,why=addon.Functions.cache.getCached(cache,platform.GetHealthForecastValueObservation,platform,unit,kind)
if not platform:CanReadValue(value) then return nil,'restricted-value' end
if value==nil then return nil,why or 'health-data-unavailable' end
local valid,reason=finite(platform,value)
if not valid then return nil,reason end
if value<0 then return nil,'invalid-health-forecast-number' end
return value