呼叫方式
addon.Platform:GetItemInfoInstant(item)
可直接透過 addon 使用,不需要相依項目。
作用
讀取正規化的原生物品分類中繼資料。記錄包含正規的 itemID、classID 與 subClassID,以及在可讀且非空時的 equipLoc(未在地化的 INVTYPE_* 裝備位置標記);不要求物品顯示文字已載入。中繼資料缺少、失敗、格式錯誤或受限時傳回 nil 及原因。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台轉接器(使用冒號呼叫時隱含傳入)。 |
item | number | string | 要分類的正數物品 ID,或原生可辨識的物品名稱/連結。 |
傳回值
| 1 | table | nil | 可讀的正規物品分類記錄(itemID、classID、subClassID 與選用的 equipLoc),無法使用時為 nil。 |
|---|---|---|
| 2 | string | nil | 結果為 nil 時的驗證或可用性原因。 |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
機密值(正式版與永久)
在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。
範例
local item = addon.Platform:GetItemInfoInstant(5512) -- Healthstone
if not item then return nil end
return item.classID == 0 -- consumable相依項目
finite→Platform.items.finiteidentifier→Platform.items.identifier
原始碼
Platform/items.lua,第 132 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Platform.items.GetItemInfoInstant(self, item)
local valid,reason=identifier(item)
if not valid then return nil,reason end
local fn=C_Item and C_Item.GetItemInfoInstant
if type(fn)~='function' then fn=GetItemInfoInstant end
if type(fn)~='function' then return nil,'missing-api' end
local ok,tuple=pcall(function() return {fn(item)} end)
if not ok then return nil,'api-error' end
local id,class,subclass=tuple[1],tuple[6],tuple[7]
if not self:CanReadValue(id) or not self:CanReadValue(class) or not self:CanReadValue(subclass) then return nil,'restricted-value' end
if id==nil then return nil,'item-data-unavailable' end
if not finite(id) or id<=0 or id%1~=0 or not finite(class) or class%1~=0
or not finite(subclass) or subclass%1~=0 or type(item)=='number' and id~=item then return nil,'invalid-api-result' end
-- The equip location is a non-localized INVTYPE_* token (two-hand,
-- shield, ...). An empty or unreadable token is simply absent.
local equipLoc=tuple[4]
if not self:CanReadValue(equipLoc) or type(equipLoc)~='string' or equipLoc=='' then equipLoc=nil end
return {itemID=id,classID=class,subClassID=subclass,equipLoc=equipLoc}




