调用方式
Conditions.misc.difficultyName(id)
记录依赖项 Conditions.misc.difficultyName,然后按该名称调用。带命名空间的调用不会传入 self:请使用冒号调用,或自行传入该对象。
作用
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".
参数
| 名称 | 类型 | 作用 |
|---|---|---|
id | number | Difficulty ID. |
返回值
| 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. |
|---|
版本
内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。
- 该版本不可用(原因见提示)
- 仅在暴雪的弃用兼容层开启时
| 游戏 API | |||||
|---|---|---|---|---|---|
GetDifficultyInfo |
秘密值(正式服和永久服)
在正式服和永久服上,游戏交给插件的是秘密值。此辅助函数会检查它读取的内容(addon.Platform:CanReadValue),遇到无法比较的秘密值时返回 nil 并附上原因(例如 restricted-value),而不是返回该秘密值。请将 nil 视为不可用,而不是假。
插件如何调用它
- 副本 (print)
parts[#parts + 1] = string.format(L["difficulty %s"], difficultyName(value.difficulty) or tostring(value.difficulty))
依赖项
difficultyKind→Conditions.misc.difficultyKind
源码
Conditions/misc.lua,第 296 行。在游戏中为只读;“复制”会生成一份可编辑的副本。
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




