Llamar como
Platform.casting.spellIdentity(id)
Registra la dependencia Platform.casting.spellIdentity y después llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa el objeto tú mismo.
Qué hace
Validates the spell ID field of a cast or channel result. Returns the ID when it is a readable positive finite integer; otherwise nil with "restricted-value" (secret), "cast-spell-unavailable" (nil) or "invalid-api-result".
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
id | any | Spell ID value from the UnitCastingInfo or UnitChannelInfo result. |
Retornos
| 1 | number | nil | The validated spell ID, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the ID 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 usa una alternativa o devuelve nil con un motivo.
No lee directamente ninguna API del juego.
Valores secretos (Retail y Forever)
En Retail y Forever, el juego les entrega a los addons valores secretos. Esta función auxiliar verifica 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
Platform.casting.GetUnitCastObservationrecord.spellID,record.spellReason=spellIdentity(tuple[kind=='cast' and 9 or 8])
Dependencias
platform(builtin:Platform/casting.lua:platform)
Código fuente
Platform/casting.lua, línea 53. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.casting.spellIdentity(id)
if not platform:CanReadValue(id) then return nil,'restricted-value' end
if id==nil then return nil,'cast-spell-unavailable' end
if type(id)~='number' or id~=id or id<=0 or id==math.huge or id%1~=0 then return nil,'invalid-api-result' end
return id