參考資料 › 函式參考 › Conditions

Conditions.item.get_item_desc

相依項目

呼叫方式

Conditions.item.get_item_desc(items)

記錄相依項目 Conditions.item.get_item_desc,然後以該名稱呼叫。含命名空間的呼叫不會傳入 self:請使用冒號呼叫,或自行傳入該物件。

作用

Describes an item reference for the item condition descriptions: an item set name (white for a profile set, cyan for a global one), or the first item's link or name followed by how many others are listed. Returns nil when the reference is invalid, the set is unknown, or the list is empty.

參數

名稱類型作用
itemsstring | tableItem set name, or an array of item IDs or names.

傳回值

1string | nilLocalized description, or nil when nothing can be described.

版本

內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。

它不會直接讀取任何遊戲 API。

插件如何呼叫它

  • 背包中有物品 (print)
    item = Functions.presentation.nullable(get_item_desc(value.item), L["<item>"]),
  • 已裝備物品 (print)
    return Literal.phrase(L["you {{!have|do not have}} {item} equipped"], {item = Functions.presentation.nullable(get_item_desc(value.item), L["<item>"])})
  • 物品可用 (print)
    item = Functions.presentation.nullable(get_item_desc(value.item), L["<item>"]),
  • 物品冷卻 (print)
    item = Functions.presentation.nullable(get_item_desc(value.item), L["<item>"]),
  • 物品在射程內 (print)
    item = Functions.presentation.nullable(get_item_desc(value.item), L["<item>"]),

相依項目

原始碼

Conditions/item.lua,第 62 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。

Conditions.item.get_item_desc(items)
    if not addon:IsConditionItemReference(items) then return nil end
    local itemsets = addon.db.profile.itemsets
    local global_itemsets = addon.db.global.itemsets
    if itemsets~=nil and type(itemsets)~='table' or global_itemsets~=nil and type(global_itemsets)~='table' then return nil end

    if type(items) == "string" then
        local set=(itemsets or {})[items];local tint=color.WHITE
        if set==nil then set=(global_itemsets or {})[items];tint=color.CYAN end
        if type(set)=='table' and type(set.name)=='string' then return string.format(L["a %s item set item"],tint..set.name..color.RESET) end
    elseif items and #items > 0 then
        local info=addon.Platform:GetItemMetadata(items[1])
        local link=info and (info.link or info.name) or items[1]
        if #items > 1 then
            return string.format(L["%s or %d others"], link, #items-1)
        else
            return link
        end
    end
    return nil

返回函式參考