Appel
Platform.casting.durationSeconds(starting, ending)
Enregistrez la dépendance Platform.casting.durationSeconds, puis appelez-la sous ce nom. Un appel par espace de noms ne transmet pas self : utilisez un appel avec deux-points ou passez l'objet vous-même.
Ce qu'elle fait
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.
Arguments
| Nom | Type | Ce qu'elle fait |
|---|---|---|
starting | number | nil | Cast start time in milliseconds (GetTime() scale times 1000). |
ending | number | nil | Cast end time in milliseconds (GetTime() scale times 1000). |
Retours
| 1 | number | nil | Total cast length in seconds, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the length is nil. |
Éditions
Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.
Elle ne lit directement aucune API du jeu.
Valeurs secrètes (Retail et Forever)
Sur Retail et Forever, le jeu transmet aux addons des valeurs secrètes. Cette fonction utilitaire vérifie ce qu'elle lit (addon.Platform:CanReadValue) et renvoie nil avec une raison telle que restricted-value au lieu d'une valeur secrète qu'elle ne peut pas comparer. Traitez nil comme indisponible, pas comme false.
Comment l'addon l'appelle
Platform.casting.GetUnitCastObservationrecord.durationSeconds,record.durationReason=durationSeconds(tuple[4],tuple[5])
Dépendances
finite→Platform.casting.finiteplatform(builtin:Platform/casting.lua:platform)
Source
Platform/casting.lua, ligne 42. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
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