Llamar como
Conditions.misc.difficultyName(id)
Registra la dependencia Conditions.misc.difficultyName y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.
Qué hace
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".
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
id | number | Difficulty ID. |
Retornos
| 1 | string | nil | The name, or nil when the client does not know the ID or hides its name, so callers fall back to the number. |
|---|
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.
- No disponible en esa edición (el motivo aparece en la información emergente)
- Solo mientras estén activas las alternativas de Blizzard para API obsoletas
| API del juego | |||||
|---|---|---|---|---|---|
GetDifficultyInfo |
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Cómo la llama el addon
- Estancia (print)
parts[#parts + 1] = string.format(L["difficulty %s"], difficultyName(value.difficulty) or tostring(value.difficulty))
Dependencias
difficultyKind→Conditions.misc.difficultyKind
Código fuente
Conditions/misc.lua, línea 296. Solo lectura en el juego; Duplicar crea una copia editable.
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




