Referência › Referência de funções › Platform

Platform.spells.identifier

dependência

Chame como

Platform.spells.identifier(value, idOnly)

Registre a dependência Platform.spells.identifier 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 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.

Argumentos

NomeTipoO que faz
valueanySpell ID or name to validate.
idOnlyboolean | nilTrue accepts numeric spell IDs only and rejects names.

Retornos

1booleanTrue when value is acceptable; false otherwise.
2string | nilrestricted-value or invalid-spell when rejected.

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

Dependências

Código-fonte

Platform/spells.lua, linha 22. Somente leitura no jogo; Duplicar cria uma cópia editável.

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"

Voltar para Referência de funções