Reference › Function reference › Platform

Platform.casting.spellIdentity

dependency

Call as

Platform.casting.spellIdentity(id)

Record the dependency Platform.casting.spellIdentity, 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 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".

Arguments

NameTypeWhat it does
idanySpell ID value from the UnitCastingInfo or UnitChannelInfo result.

Returns

1number | nilThe validated spell ID, or nil when unavailable.
2string | nilReason when the ID is nil.

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/casting.lua, line 53. Read only in game; Duplicate makes an editable copy.

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

Back to Function reference