Chiamala come
Platform.casting.remainingSeconds(ending)
Registra la dipendenza Platform.casting.remainingSeconds, poi chiamala con quel nome. Una chiamata con spazio dei nomi non passa self: usa una chiamata con i due punti o passa tu l'oggetto.
Cosa fa
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.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Valori restituiti
| 1 | number | nil | Seconds remaining, never negative; nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the result is nil. |
Edizioni
Le funzioni di supporto integrate sono registrate su ogni edizione. Ciò che cambia è l'API di gioco che leggono; dove ne manca una, la funzione di supporto ripiega su un'alternativa o restituisce nil con un motivo.
- Non disponibile su quell'edizione (il motivo è nel suggerimento)
- Solo mentre sono attivi i ripieghi di Blizzard per le API deprecate
| API di gioco | |||||
|---|---|---|---|---|---|
GetTime |
Valori segreti (Retail e Forever)
Su Retail e Forever il gioco fornisce agli addon valori segreti. Questa funzione di supporto controlla ciò che legge (addon.Platform:CanReadValue) e restituisce nil con un motivo come restricted-value invece di un valore segreto che non può confrontare. Considera nil come non disponibile, non come false.
Come la chiama l'addon
Platform.casting.GetUnitCastObservationrecord.remainingSeconds,record.remainingReason=remainingSeconds(tuple[5])
Dipendenze
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Sorgente
Platform/casting.lua, riga 23. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
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)




