Как вызывать
Platform.casting.spellIdentity(id)
Запишите зависимость Platform.casting.spellIdentity и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.
Что делает
Validates the spell ID field of a cast or channel result. Returns the ID when it is a readable positive finite integer; otherwise nil with "restricted-value" (secret), "cast-spell-unavailable" (nil) or "invalid-api-result".
Аргументы
| Имя | Тип | Что делает |
|---|---|---|
id | any | Spell ID value from the UnitCastingInfo or UnitChannelInfo result. |
Возвращает
| 1 | number | nil | The validated spell ID, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the ID is nil. |
Издания
Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.
Не читает игровой API напрямую.
Секретные значения (Retail и Forever)
В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.
Как его вызывает аддон
Platform.casting.GetUnitCastObservationrecord.spellID,record.spellReason=spellIdentity(tuple[kind=='cast' and 9 or 8])
Зависимости
platform(builtin:Platform/casting.lua:platform)
Исходный код
Platform/casting.lua, строка 53. В игре только для чтения; «Дублировать» создаёт редактируемую копию.
Platform.casting.spellIdentity(id)
if not platform:CanReadValue(id) then return nil,'restricted-value' end
if id==nil then return nil,'cast-spell-unavailable' end
if type(id)~='number' or id~=id or id<=0 or id==math.huge or id%1~=0 then return nil,'invalid-api-result' end
return id