Как вызывать
Platform.casting.durationSeconds(starting, ending)
Запишите зависимость Platform.casting.durationSeconds и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.
Что делает
Computes the total length of a cast or channel in seconds from the millisecond start and end times in a UnitCastingInfo or UnitChannelInfo result. Returns nil with "restricted-value" when either time is secret, "cast-time-unavailable" when either is nil, or "invalid-api-result" when a time is not a finite number, the start is negative or the end is not after the start.
Аргументы
| Имя | Тип | Что делает |
|---|---|---|
starting | number | nil | Cast start time in milliseconds (GetTime() scale times 1000). |
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Возвращает
| 1 | number | nil | Total cast length in seconds, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the length is nil. |
Издания
Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.
Не читает игровой API напрямую.
Секретные значения (Retail и Forever)
В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.
Как его вызывает аддон
Platform.casting.GetUnitCastObservationrecord.durationSeconds,record.durationReason=durationSeconds(tuple[4],tuple[5])
Зависимости
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Исходный код
Platform/casting.lua, строка 42. В игре только для чтения; «Дублировать» создаёт редактируемую копию.
Platform.casting.durationSeconds(starting, ending)
if not platform:CanReadValue(starting) or not platform:CanReadValue(ending) then return nil,'restricted-value' end
if starting==nil or ending==nil then return nil,'cast-time-unavailable' end
if not finite(starting) or not finite(ending) or starting<0 or ending<=starting then return nil,'invalid-api-result' end
return (ending-starting)/1000