Reference › Function reference › Platform

Platform.spells.identifier

dependency

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

NameTypeWhat it does
valueanySpell ID or name to validate.
idOnlyboolean | nilTrue accepts numeric spell IDs only and rejects names.

Returns

1booleanTrue when value is acceptable; false otherwise.
2string | nilrestricted-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

Dependencies

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"

Back to Function reference