Call as
Platform.spells.identifier(value, idOnly)
Record the dependency Platform.spells.identifier, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.
What it does
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.
Arguments
| Name | Type | What it does |
|---|---|---|
value | any | Spell ID or name to validate. |
idOnly | boolean | nil | True accepts numeric spell IDs only and rejects names. |
Returns
| 1 | boolean | True when value is acceptable; false otherwise. |
|---|---|---|
| 2 | string | nil | restricted-value or invalid-spell when rejected. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
It reads no game API directly.
Secret values (Retail and Forever)
On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.
How the addon calls it
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)
Dependencies
platform(builtin:Platform/spells.lua:platform)
Source
Platform/spells.lua, line 22. Read only in game; Duplicate makes an editable copy.
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"