Как вызывать
Core.health_forecast_conditions.nativeValue(self, unit, kind, cache)
Запишите зависимость Core.health_forecast_conditions.nativeValue и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.
Что делает
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.
Аргументы
| Имя | Тип | Что делает |
|---|---|---|
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. |
Возвращает
| 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. |
Издания
Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.
Не читает игровой API напрямую.
Секретные значения (Retail и Forever)
В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.
Как его вызывает аддон
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
Зависимости
Исходный код
Core/health_forecast_conditions.lua, строка 52. В игре только для чтения; «Дублировать» создаёт редактируемую копию.
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