Reference › Function reference › Platform

Platform.health_forecast.readField

dependency

Call as

Platform.health_forecast.readField(self, object, key)

Record the dependency Platform.health_forecast.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] in protected mode. Returns the value (possibly nil), or nil with "restricted-value" when the object or the value is secret, "invalid-api-result" when object is not a table, or "api-error" when indexing raises an error (for example, from a metatable).

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (normally addon.Platform), used for its CanReadValue check.
objecttableTable to index; any other type is rejected.
keyanyField name to read.

Returns

1anyThe field value, possibly nil; nil on failure.
2string | nilReason on failure; nil on success.

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

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

Platform.health_forecast.readField(self, object, key)
    if not self:CanReadValue(object) then return nil,'restricted-value' end
    if type(object)~='table' then return nil,'invalid-api-result' end
    local ok,value=pcall(function() return object[key] end)
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(value) then return nil,'restricted-value' end
    return value

Back to Function reference