Llamar como
Platform.mobinfo2.presence(self, unit)
Registra la dependencia Platform.mobinfo2.presence y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.
Qué hace
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
| Nombre | Tipo | Qué hace |
|---|---|---|
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. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.
- No disponible en esa edición (el motivo aparece en la información emergente)
- Solo mientras estén activas las alternativas de Blizzard para API obsoletas
| API del juego | |||||
|---|---|---|---|---|---|
UnitExists |
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Ejemplo
-- needs the dependency Platform.mobinfo2.presence
local exists = Platform.mobinfo2.presence(addon.Platform, "target")
if exists == nil then return nil end
return existsCódigo fuente
Platform/mobinfo2.lua, línea 46. Solo lectura en el juego; Duplicar crea una copia editable.
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




