Riferimento › Riferimento delle funzioni › Platform

Platform.mobinfo2.presence

dipendenza

Chiamala come

Platform.mobinfo2.presence(self, unit)

Registra la dipendenza Platform.mobinfo2.presence, poi chiamala con quel nome. Una chiamata con spazio dei nomi non passa self: usa una chiamata con i due punti o passa tu l'oggetto.

Cosa fa

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.

Argomenti

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

Valori restituiti

1boolean | nilTrue when the unit exists, false when it does not; nil when unavailable.
2string | nilReason when the result is nil.

Edizioni

Le funzioni di supporto integrate sono registrate su ogni edizione. Ciò che cambia è l'API di gioco che leggono; dove ne manca una, la funzione di supporto ripiega su un'alternativa o restituisce nil con un motivo.

  • Non disponibile su quell'edizione (il motivo è nel suggerimento)
  • Solo mentre sono attivi i ripieghi di Blizzard per le API deprecate
API di giocoClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic progressionForeverRetail

Valori segreti (Retail e Forever)

Su Retail e Forever il gioco fornisce agli addon valori segreti. Questa funzione di supporto controlla ciò che legge (addon.Platform:CanReadValue) e restituisce nil con un motivo come restricted-value invece di un valore segreto che non può confrontare. Considera nil come non disponibile, non come false.

Esempio

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

Sorgente

Platform/mobinfo2.lua, riga 46. Nel gioco è in sola lettura; Duplica crea una copia modificabile.

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

Torna a Riferimento delle funzioni