Reference › Function reference › Conditions

Conditions.misc.difficultyName

dependency

Call as

Conditions.misc.difficultyName(id)

Record the dependency Conditions.misc.difficultyName, 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

The display name of an instance difficulty ID: the game's name for it (GetDifficultyInfo) with the kind of group in parentheses when the game gives one. 0 is "Not in an instance".

Arguments

NameTypeWhat it does
idnumberDifficulty ID.

Returns

1string | nilThe name, or nil when the client does not know the ID or hides its name, so callers fall back to the number.

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.

  • Not available on that edition (the reason is in the tooltip)
  • Only while Blizzard's deprecation fallbacks are on
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
GetDifficultyInfoClassic EraTBC AnniversaryClassic progressionForeverRetail

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

  • Instance (print)
    parts[#parts + 1] = string.format(L["difficulty %s"], difficultyName(value.difficulty) or tostring(value.difficulty))

Dependencies

Source

Conditions/misc.lua, line 296. Read only in game; Duplicate makes an editable copy.

Conditions.misc.difficultyName(id)
    if id == 0 then return L["Not in an instance"] end
    if type(id) ~= "number" then return nil end
    local ok, name, group = pcall(GetDifficultyInfo, id)
    if ok and addon.Platform:CanReadValue(name) and type(name) == "string" and name ~= "" then
        local kind = addon.Platform:CanReadValue(group) and difficultyKind(group)
        if kind then return string.format(L["%s (%s)"], name, kind) end
        return name
    end
    return nil

Back to Function reference