Call as
Functions.presentation.playerize(unit, player, nonplayer)
Record it as a dependency named Functions.presentation.playerize (accepting the completion does this), then call it by that name.
What it does
Choose the supplied player value only for the literal player unit token; every other unit selects the nonplayer value. Selected false and nil values are preserved.
Arguments
| Name | Type | What it does |
|---|---|---|
unit | string | nil | Unit token to compare with the literal player token. |
player | any | Value returned when unit is player. |
nonplayer | any | Value returned for every other unit. |
Returns
| 1 | any | The selected value, including false or nil. |
|---|
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
- Attackable (print)
return string.format(Functions.presentation.playerize(value.unit, L["%s {{!are|are not}} attackable"], L["%s {{!is|is not}} attackable"]), Functions.presentation.nullable(addon.units[value.unit], L["<unit>"])) - Buff Present (print)
return AuraLiteral.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!have|do not have}} {aura}"], L["{unit} {{!has|does not have}} {aura}"]), { - Buff Time Remaining (print)
return AuraSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!have|do not have}} {aura} where {remaining} {comparison} {duration}"], L["{unit} {{!has|does not have}} {aura} where {remaining} {comparison} {duration}"]), { - Casting (print)
return string.format(Functions.presentation.playerize(value.unit, L["%s {{!are|are not}} currently casting"], L["%s {{!is|is not}} currently casting"]), - Specific Spell Casting (print)
return LiteralSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!are|are not}} currently casting {spell}"], L["{unit} {{!is|is not}} currently casting {spell}"]), { - Channeling (print)
return string.format(Functions.presentation.playerize(value.unit, L["%s {{!are|are not}} currently channeling"], L["%s {{!is|is not}} currently channeling"]), - Specific Spell Channeling (print)
return LiteralSummary.phrase(Functions.presentation.playerize(value.unit, L["{unit} {{!are|are not}} currently channeling {spell}"], L["{unit} {{!is|is not}} currently channeling {spell}"]), { - In Combat (print)
return string.format(Functions.presentation.playerize(value.unit, L["%s {{!are|are not}} in combat"], L["%s {{!is|is not}} in combat"]),
and 13 more: Combat Action History (print), Combat Action History Time (print), Debuff Present (print), Debuff Time Remaining (print), Debuff Type Present (print), Distance (print), Hostile (print), Immune (print), Is Same As (print), Level (print), Raid Mark (print), PVP Flagged (print), Has Stealable Buff (print)
Source
Functions/presentation.lua, line 56. Read only in game; Duplicate makes an editable copy.
Functions.presentation.playerize(unit, player, nonplayer)
if (unit == "player") then
return player
else
return nonplayer
end