Reference › Function reference › Platform

Platform.mobinfo2.presence

dependency

Call as

Platform.mobinfo2.presence(self, unit)

Record the dependency Platform.mobinfo2.presence, 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

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.

Arguments

NameTypeWhat it does
selfRMPlatformRotation Master platform adapter (normally addon.Platform), used for its CanReadValue check.
unitstringUnit token passed unchanged to UnitExists; not validated here.

Returns

1boolean | nilTrue when the unit exists, false when it does not; nil when unavailable.
2string | nilReason when the result 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.

  • Not available on that edition (the reason is in the tooltip)
  • Only while Blizzard's deprecation fallbacks are on
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic progressionForeverRetail

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.

Example

-- needs the dependency Platform.mobinfo2.presence
local exists = Platform.mobinfo2.presence(addon.Platform, "target")
if exists == nil then return nil end
return exists

Source

Platform/mobinfo2.lua, line 46. Read only in game; Duplicate makes an editable copy.

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

Back to Function reference