Call as
Functions.forecast.readField(platform, object, key)
Record the dependency Functions.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] for Functions.forecast.calculate without letting a restricted value, a non-table object or an index error escape.
Arguments
| Name | Type | What it does |
|---|---|---|
platform | RMPlatform | Platform whose CanReadValue decides readability. |
object | any | Table to read, such as the history record or one of its rows. |
key | any | Key to read, such as "damage" or "time". |
Returns
| 1 | any | The field's value (possibly nil), or nil on failure. |
|---|---|---|
| 2 | string | nil | Reason on failure: restricted-value, invalid-forecast-history or forecast-history-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
Functions.forecast.calculatelocal rows,why=readField(platform,history,name)
Source
Functions/forecast.lua, line 38. Read only in game; Duplicate makes an editable copy.
Functions.forecast.readField(platform, object, key)
if not platform:CanReadValue(object) then return nil,'restricted-value' end
if type(object)~='table' then return nil,'invalid-forecast-history' end
local ok,value=pcall(function() return object[key] end)
if not ok then return nil,'forecast-history-error' end
if not platform:CanReadValue(value) then return nil,'restricted-value' end
return value