Chame como
Platform.casting.remainingSeconds(ending)
Registre a dependência Platform.casting.remainingSeconds 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
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
| Nome | Tipo | O que faz |
|---|---|---|
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Retornos
| 1 | number | nil | Seconds remaining, never negative; nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the result 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.
- Indisponível nessa edição (o motivo está na dica)
- Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
| API do jogo | |||||
|---|---|---|---|---|---|
GetTime |
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
Platform.casting.GetUnitCastObservationrecord.remainingSeconds,record.remainingReason=remainingSeconds(tuple[5])
Dependências
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Código-fonte
Platform/casting.lua, linha 23. Somente leitura no jogo; Duplicar cria uma cópia editável.
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)




