Referencia › Referencia de funciones › Platform

Platform.casting.remainingSeconds

dependencia

Llamar como

Platform.casting.remainingSeconds(ending)

Registra la dependencia Platform.casting.remainingSeconds 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

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.

Argumentos

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

Retornos

1number | nilSeconds remaining, never negative; nil when unavailable.
2string | nilReason when the result 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 disponible en esa edición (el motivo aparece en la información emergente)
  • Solo mientras estén activas las alternativas de Blizzard para API obsoletas
API del juegoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
GetTimeClassic EraTBC AnniversaryClassic ProgressionForeverRetail

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 23. Solo lectura en el juego; Duplicar crea una copia editable.

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)

Volver a Referencia de funciones