Llamar como
Platform.spells.identifier(value, idOnly)
Registra la dependencia Platform.spells.identifier y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.
Qué hace
Validates a spell argument. Accepts a readable positive finite integer spell ID or, unless idOnly is true, a nonempty spell name string. Returns true, or false with "restricted-value" for a secret value or "invalid-spell" for anything else.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
value | any | Spell ID or name to validate. |
idOnly | boolean | nil | True accepts numeric spell IDs only and rejects names. |
Retornos
| 1 | boolean | True when value is acceptable; false otherwise. |
|---|---|---|
| 2 | string | nil | restricted-value or invalid-spell when rejected. |
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 recurre a 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 entrega a los addons valores secretos. Esta función auxiliar comprueba 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.spells.GetSpellChargeslocal valid,reason=identifier(spell)Platform.spells.GetSpellCooldownlocal valid, reason = identifier(spell)Platform.spells.IsAutoRepeatActivelocal valid,reason=identifier(spellID,true)Platform.spells.cooldownValueslocal valid,reason=identifier(spell)
Dependencias
platform(builtin:Platform/spells.lua:platform)
Código fuente
Platform/spells.lua, línea 22. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.spells.identifier(value, idOnly)
if not platform:CanReadValue(value) then return false, "restricted-value" end
if type(value) == "number" and value > 0 and value < math.huge and value % 1 == 0 then return true end
if not idOnly and type(value) == "string" and #value > 0 then return true end
return false, "invalid-spell"