Reference › Function reference › Functions

Functions.presentation.nullable

public

Call as

Functions.presentation.nullable(value, default)

Record it as a dependency named Functions.presentation.nullable (accepting the completion does this), then call it by that name.

Also accepted under the former namespace utils.

What it does

Return a present value unchanged, or a red display placeholder for nil. Use for readable condition labels, not as a boolean fallback.

Arguments

NameTypeWhat it does
valueanyValue to display; false is preserved.
defaultstring | nilMissing-value display text; omitted uses the localized value placeholder.

Returns

1anyOriginal non-nil value, 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

  • Action Context (print)
    Functions.presentation.nullable(addon.actionContexts[value.context], L["<action bar>"]))
  • Any Spell Available (print)
    return string.format(L["%s {{!is|is not}} available"], Functions.presentation.nullable(link, L["<spell>"]))
  • Any Spell Charges (print)
    Functions.presentation.compareString(value.operator, string.format(L["number of charges on %s"], Functions.presentation.nullable(link, L["<spell>"])), Functions.presentation.nullable(value.value)))
  • Any Spell Cooldown (print)
    Functions.presentation.compareString(value.operator, string.format(L["cooldown on %s"],  Functions.presentation.nullable(link, L["<spell>"])),
  • Any Spell In Range (print)
    return string.format(L["%s {{!is|is not}} in range"], Functions.presentation.nullable(link, L["<spell>"]))
  • Any Spell Recharge Time (print)
    Functions.presentation.compareString(value.operator, string.format(L["recharge time on %s"], Functions.presentation.nullable(link, L["<spell>"])),
  • Assisted Combat Rotation Spell (print)
    return string.format(L["%s {{!is|is not}} in Blizzard's Assisted Combat rotation"], Functions.presentation.nullable(link, L["<spell>"]))
  • Assisted Combat Suggestion (print)
    return string.format(L["Assisted Combat {{!suggests|does not suggest}} %s"], Functions.presentation.nullable(link, L["<spell>"]))

and 120 more: Attackable (print), Boss Mod Encounter Stage (print), Boss Mod Timer (print), Buff Present (print), Buff Time Remaining (print), Buff Stacks (print), Have Item In Bags (print), Casting (print), Cast Progress (print), Cast Time Remaining (print), Specific Spell Casting (print), Cast Interruptible (print), Channeling (print), Channel Progress (print), Channel Time Remaining (print), Specific Spell Channeling (print), Channel Interruptible (print), Class (print), Unit Classification (print), Class In Group (print), In Combat (print), Combat Action History (print), Combat Action History Time (print), Creature Type (print), Debuff Present (print), Debuff Time Remaining (print), Debuff Stacks (print), Debuff Type Present (print), Distance (print), Distance Count (print), Eclipse (print), Extended Character Stat (print), Extended Character Stat Percentage (print), Hostile (print), Have Item Equipped (print), Shapeshift Form (print), Glyph (print), In Group (print), Group Count (print), Health (print), Health Percentage (print), Hero Talent Tree (print), Immune (print), Instance (print), Is Same As (print), Item Available (print), Item Cooldown (print), Item In Range (print), Mythic+ Keystone Level (print), Level (print), Loss Of Control Blocked (print), Loss Of Control Type (print), Mana (print), Mana Percentage (print), Raid Mark (print), Raid Mark Count (print), Pet Spell Active or Pending (print), Pet Spell Available (print), Pet Spell Charges (print), Pet Spell Cooldown (print), Pet Spell Cast History (print), Pet Spell Cast History Time (print), Pet Spell In Range (print), Pet Spell Recharge Time (print), Pet Happiness (print), Have Named Pet (print), Points (print), Power (print), Power Percentage (print), Allies Within Range (print), Health Within Range (print), Health Percentage Within Range (print), Health Percentage Count Within Range (print), Health Count Within Range (print), Mana Within Range (print), Mana Percentage Within Range (print), Mana Percentage Count Within Range (print), Mana Count Within Range (print), PVP Flagged (print), Resistant (print), Role (print), Runes (print), Rune Cooldown (print), Engraved Rune (print), Runner (print), Level (print), Item Set Pieces Equipped (print), Specialization (print), Spell Active or Pending (print), Spell Auto-Repeat Active (print), Spell Available (print), Spell Charges (print), Spell Cooldown (print), Spell Proc Glow (print), Spell Cast History (print), Spell Cast History Time (print), Spell In Range (print), Spell Recharge Time (print), Stagger (print), Character Stat (print), Has Stealable Buff (print), Weapon Swing Time (print), Weapon Swing Time Remaining (print), Talent (print), Talent Tree Points (print), Threat (print), Threat Count (print), Time Since Combat Start (print), Totem Present (print), Totem Time Remaining (print), Specific Totem Present (print), Specific Totem Time Remaining (print), Time Until Health (print), Time Until Health Percentage (print), Weapon Enchant Type (print), Weapon Enchant Time Remaining (print), Weapon Enchant Stacks (print), Weapon Type (print), Zone (print), Zone PVP (print)

Dependencies

Source

Functions/presentation.lua, line 23. Read only in game; Duplicate makes an editable copy.

Functions.presentation.nullable(value, default)
    if value == nil then
        if default ~= nil then
            return color.RED .. default .. color.RESET
        else
            return color.RED .. L["<value>"] .. color.RESET
        end
    end
    return value

Back to Function reference