Llamar como
Platform.casting.durationSeconds(starting, ending)
Registra la dependencia Platform.casting.durationSeconds y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.
Qué hace
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.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
starting | number | nil | Cast start time in milliseconds (GetTime() scale times 1000). |
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Retornos
| 1 | number | nil | Total cast length in seconds, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the length is nil. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.
No lee directamente ninguna API del juego.
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Cómo la llama el addon
Platform.casting.GetUnitCastObservationrecord.durationSeconds,record.durationReason=durationSeconds(tuple[4],tuple[5])
Dependencias
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Código fuente
Platform/casting.lua, línea 42. Solo lectura en el juego; Duplicar crea una copia editable.
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