Chame como
Platform.mobinfo2.presence(self, unit)
Registre a dependência Platform.mobinfo2.presence 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
Checks whether a unit exists with one protected UnitExists call. Returns true or false when readable; otherwise nil with "missing-api", "api-error", "restricted-value", "unit-data-unavailable" (nil result) or "invalid-api-result". GetMobInfo2Observation shares this result through the evaluation cache.
Argumentos
| Nome | Tipo | O que faz |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (normally addon.Platform), used for its CanReadValue check. |
unit | string | Unit token passed unchanged to UnitExists; not validated here. |
Retornos
| 1 | boolean | nil | True when the unit exists, false when it does not; nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason when the result 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.
- Indisponível nessa edição (o motivo está na dica)
- Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
| API do jogo | |||||
|---|---|---|---|---|---|
UnitExists |
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.
Exemplo
-- needs the dependency Platform.mobinfo2.presence
local exists = Platform.mobinfo2.presence(addon.Platform, "target")
if exists == nil then return nil end
return existsCódigo-fonte
Platform/mobinfo2.lua, linha 46. Somente leitura no jogo; Duplicar cria uma cópia editável.
Platform.mobinfo2.presence(self, unit)
if type(UnitExists)~='function' then return nil,'missing-api' end
local ok,exists=pcall(UnitExists,unit)
if not ok then return nil,'api-error' end
if not self:CanReadValue(exists) then return nil,'restricted-value' end
if exists==nil then return nil,'unit-data-unavailable' end
if type(exists)~='boolean' then return nil,'invalid-api-result' end
return exists




