呼叫方式
Conditions.totem.findSpecific(value, cache, start, compareTime)
記錄相依項目 Conditions.totem.findSpecific,然後以該名稱呼叫。含命名空間的呼叫不會傳入 self:請使用冒號呼叫,或自行傳入該物件。
作用
Searches the totem slots for an active totem matching value.spell, by spell ID or name (only the exact spell ID when value.ranked is set). With compareTime it also requires the totem's remaining time, rounded to 3 decimals, to pass value.operator and value.value; an unreadable slot makes a non-match unavailable.
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
value | table | Condition settings: spell, ranked and, for timed checks, operator and value. |
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
start | number | nil | Evaluation start time; nil uses GetTime(). |
compareTime | boolean | True to also compare the remaining time. |
傳回值
| 1 | boolean | nil | True when a matching totem is found, false when none is, or nil when a slot could not be read. |
|---|---|---|
| 2 | string | nil | Reason for nil, such as totem-data-unavailable, totem-rank-unavailable or totem-identity-unavailable. |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
它不會直接讀取任何遊戲 API。
插件如何呼叫它
相依項目
observe→Conditions.totem.observeplatform(builtin:Conditions/totem.lua:platform)remaining→Conditions.totem.remaining
原始碼
Conditions/totem.lua,第 102 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Conditions.totem.findSpecific(value, cache, start, compareTime)
local target,reason=observe(cache,platform.GetSpellInfo,value.spell)
if not target then return nil,reason end
local count,why=observe(cache,platform.GetTotemSlotCount)
if not count then return nil,why end
local unavailable
for slot=1,count do
local record,problem=observe(cache,platform.GetTotemInfo,slot)
if not record then unavailable=unavailable or problem or "totem-data-unavailable"
elseif record.active and remaining(record,start)>0 then
local matches=false
if value.ranked then
if record.spellID then matches=record.spellID==value.spell
elseif record.name==target.name or record.name=="" then unavailable=unavailable or "totem-rank-unavailable" end
else
matches=record.spellID==value.spell or record.name==target.name
if not matches and record.name=="" then
local info,issue
if record.spellID then info,issue=observe(cache,platform.GetSpellInfo,record.spellID) end
if info then matches=info.name==target.name
else unavailable=unavailable or issue or "totem-identity-unavailable" end
end
end
if matches and (not compareTime or addon.compare(value.operator,addon.round(remaining(record,start),3),value.value)) then return true end
end
end
if unavailable then return nil,unavailable end
return false