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
| Name | Type | What it does |
|---|---|---|
id | any | Spell ID value from the UnitCastingInfo or UnitChannelInfo result. |
Returns
| 1 | number | nil | The validated spell ID, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason 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
Platform.casting.GetUnitCastObservationrecord.spellID,record.spellReason=spellIdentity(tuple[kind=='cast' and 9 or 8])
Dependencies
platform(builtin:Platform/casting.lua:platform)
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