Call as
Functions.presentation.nullable_value(value, array, default)
Record it as a dependency named Functions.presentation.nullable_value (accepting the completion does this), then call it by that name.
Also accepted under the former namespace utils.
What it does
Look up a table key for display, preserving non-nil results; invalid tables, missing keys and nil keys use nullable placeholder text.
Arguments
| Name | Type | What it does |
|---|---|---|
value | any | Key to look up. |
array | table | nil | Display lookup table. |
default | string | nil | Missing-value display text; omitted uses the localized value placeholder. |
Returns
| 1 | any | Original non-nil lookup result, or a colored placeholder string. |
|---|
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.
How the addon calls it
- Extended Character Stat (print)
stat = Functions.presentation.nullable_value(value.stat, ecs_state.stats, L["<stat>"]), - Extended Character Stat Percentage (print)
stat = Functions.presentation.nullable_value(value.stat, ecs_state.percentages, L["<stat>"]), - Character Stat (print)
Functions.presentation.nullable_value(value.stat, addon.stats, L["<stat>"])), Functions.presentation.nullable(value.value))
Dependencies
color(builtin:utils.lua:color)
Source
Functions/presentation.lua, line 40. Read only in game; Duplicate makes an editable copy.
Functions.presentation.nullable_value(value, array, default)
if value == nil or array == nil or type(array) ~= "table" then
if default ~= nil then
return color.RED .. default .. color.RESET
else
return color.RED .. L["<value>"] .. color.RESET
end
end
return addon.nullable(array[value], default)