Referencia › Referencia de funciones › Platform

Platform.casting.durationSeconds

dependencia

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

NombreTipoQué hace
startingnumber | nilCast start time in milliseconds (GetTime() scale times 1000).
endingnumber | nilCast end time in milliseconds (GetTime() scale times 1000).

Retornos

1number | nilTotal cast length in seconds, or nil when unavailable.
2string | nilReason 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

Dependencias

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

Volver a Referencia de funciones