Chame como
Platform.casting.spellIdentity(id)
Registre a dependência Platform.casting.spellIdentity e depois chame-a por esse nome. Uma chamada com namespace não passa self: use uma chamada com dois-pontos ou passe o objeto você mesmo.
O que faz
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".
Argumentos
| Nome | Tipo | O que faz |
|---|---|---|
id | any | Spell ID value from the UnitCastingInfo or UnitChannelInfo result. |
Retornos
| 1 | number | nil | The validated spell ID, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the ID is nil. |
Edições
As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.
Não lê nenhuma API do jogo diretamente.
Valores secretos (Retail e Forever)
No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.
Como o addon a chama
Platform.casting.GetUnitCastObservationrecord.spellID,record.spellReason=spellIdentity(tuple[kind=='cast' and 9 or 8])
Dependências
platform(builtin:Platform/casting.lua:platform)
Código-fonte
Platform/casting.lua, linha 53. Somente leitura no jogo; Duplicar cria uma cópia editável.
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