Referência › Referência de funções › Platform

Platform.casting.durationSeconds

dependência

Chame como

Platform.casting.durationSeconds(starting, ending)

Registre a dependência Platform.casting.durationSeconds e depois chame-a por esse nome. Uma chamada com namespace não passa self: use uma chamada com dois-pontos ou passe o objeto você mesmo.

O que faz

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

NomeTipoO que faz
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.

Edições

As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.

Não lê nenhuma API do jogo diretamente.

Valores secretos (Retail e Forever)

No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.

Como o addon a chama

Dependências

Código-fonte

Platform/casting.lua, linha 42. Somente leitura no jogo; Duplicar cria uma cópia editável.

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

Voltar para Referência de funções