Reference › Function reference › Core

Core.health_forecast_conditions.readField

dependency

Call as

Core.health_forecast_conditions.readField(platform, object, key)

Record the dependency Core.health_forecast_conditions.readField, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.

What it does

Reads object[key] for the health-forecast conditions without letting a restricted value, a non-table object or an index error escape.

Arguments

NameTypeWhat it does
platformRMPlatformPlatform whose CanReadValue decides readability.
objectanyTable to read, such as a damage history record.
keyanyKey to read.

Returns

1anyThe field's value (possibly nil), or nil on failure.
2string | nilReason on failure: restricted-value, invalid-health-forecast-data or health-forecast-data-error.

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.

How the addon calls it

Source

Core/health_forecast_conditions.lua, line 35. Read only in game; Duplicate makes an editable copy.

Core.health_forecast_conditions.readField(platform, object, key)
    if not platform:CanReadValue(object) then return nil,'restricted-value' end
    if type(object)~='table' then return nil,'invalid-health-forecast-data' end
    local ok,value=pcall(function() return object[key] end)
    if not ok then return nil,'health-forecast-data-error' end
    if not platform:CanReadValue(value) then return nil,'restricted-value' end
    return value

Back to Function reference