调用方式
Conditions.specialization.classChoices(class)
记录依赖项 Conditions.specialization.classChoices,然后按该名称调用。带命名空间的调用不会传入 self:请使用冒号调用,或自行传入该对象。
作用
Builds the specialization choices for one class in the SPECIALIZATION editor. Prefers the platform's live list, with icons, and otherwise falls back to the addon's built-in specialization table.
参数
| 名称 | 类型 | 作用 |
|---|---|---|
class | string | Class file token, such as "WARRIOR". |
返回值
| 1 | table | Map of specialization ID to its name, or to {text=name, icon=icon} when the platform supplies an icon. |
|---|---|---|
| 2 | number[] | Specialization IDs in display order. |
版本
内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。
它不直接读取任何游戏 API。
插件如何调用它
- 专精 (widget)
local choices, order = classChoices(v)
依赖项
CLASS_IDS(builtin:Conditions/specialization.lua:CLASS_IDS)SPECS(builtin:Conditions/specialization.lua:SPECS)SPEC_ORDER(builtin:Conditions/specialization.lua:SPEC_ORDER)specName→Conditions.specialization.specName
源码
Conditions/specialization.lua,第 176 行。在游戏中为只读;“复制”会生成一份可编辑的副本。
Conditions.specialization.classChoices(class)
local choices,order={},{}
local listed=CLASS_IDS[class] and addon.Platform.GetClassSpecializationChoices
and addon.Platform:GetClassSpecializationChoices(CLASS_IDS[class])
if listed and #listed>0 then
for _,spec in ipairs(listed) do
choices[spec.id]=spec.icon and {text=spec.name,icon=spec.icon} or spec.name
order[#order+1]=spec.id
end
return choices,order
end
for _,id in ipairs(SPEC_ORDER) do
if SPECS[id][1]==class then choices[id]=specName(id);order[#order+1]=id end
end
return choices,order