Как вызывать
Platform.casting.remainingSeconds(ending)
Запишите зависимость Platform.casting.remainingSeconds и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.
Что делает
Converts the millisecond end time of a cast or channel into the seconds left, measured against a fresh GetTime() and clamped at zero. Returns nil with "restricted-value", "cast-time-unavailable" (nil end time), "invalid-api-result", "missing-api" or "api-error" when the end time or the clock cannot be read.
Аргументы
| Имя | Тип | Что делает |
|---|---|---|
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Возвращает
| 1 | number | nil | Seconds remaining, never negative; nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the result is nil. |
Издания
Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.
- Недоступно в этом издании (причина — во всплывающей подсказке)
- Только пока включены запасные реализации Blizzard для устаревших функций
| Игровой API | |||||
|---|---|---|---|---|---|
GetTime |
Секретные значения (Retail и Forever)
В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.
Как его вызывает аддон
Platform.casting.GetUnitCastObservationrecord.remainingSeconds,record.remainingReason=remainingSeconds(tuple[5])
Зависимости
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Исходный код
Platform/casting.lua, строка 23. В игре только для чтения; «Дублировать» создаёт редактируемую копию.
Platform.casting.remainingSeconds(ending)
if not platform:CanReadValue(ending) then return nil,'restricted-value' end
if ending==nil then return nil,'cast-time-unavailable' end
if not finite(ending) or ending<0 then return nil,'invalid-api-result' end
if type(GetTime)~='function' then return nil,'missing-api' end
local ok,now=pcall(GetTime)
if not ok then return nil,'api-error' end
if not platform:CanReadValue(now) then return nil,'restricted-value' end
if not finite(now) or now<0 then return nil,'invalid-api-result' end
return math.max(0,ending/1000-now)




