Riferimento › Riferimento delle funzioni › Platform

Platform.unit_identity.GetUnitIdentityObservation

pubblica

Chiamala come

addon.Platform:GetUnitIdentityObservation(unit, otherunit)

Disponibile direttamente tramite addon; non serve alcuna dipendenza.

Cosa fa

Confronta due identificativi unità esatti usando UnitIsUnit, dopo aver verificato con UnitExists solo il primo. Se la prima unità è leggibile ma assente restituisce false senza confrontare. Osservazioni richieste mancanti, fallite, soggette a restrizioni o malformate restituiscono nil con un motivo. Non vengono aggiunte una seconda query di esistenza, una ricerca del GUID o un'identità dedotta.

Argomenti

NomeTipoCosa fa
selfRMPlatformAdattatore di piattaforma di Rotation Master (implicito nelle chiamate con due punti).
unitstringPrimo identificativo unità esatto, di cui si verifica l'esistenza prima del confronto.
otherunitstringSecondo identificativo unità esatto, passato invariato a UnitIsUnit.

Valori restituiti

1boolean | nilUguaglianza leggibile tra unità, false se la prima unità è accertata come assente, oppure nil quando le osservazioni richieste non sono disponibili.
2string | nilMotivo di policy, di convalida dell'identificativo o di indisponibilità quando il risultato dell'identità è 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
UnitIsUnitClassic 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

local same = addon.Platform:GetUnitIdentityObservation("targettarget", "player")
if same == nil then return nil end
return same -- the target is attacking you

Sorgente

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

Platform.unit_identity.GetUnitIdentityObservation(self, unit, otherunit)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not self:CanReadValue(unit) or not self:CanReadValue(otherunit) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' or type(otherunit)~='string' or otherunit=='' then return nil,'invalid-unit' end
    if type(UnitExists)~='function' then return nil,'missing-api' end
    local existsOk,exists=pcall(UnitExists,unit)
    if not existsOk 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
    if not exists then return false end
    if type(UnitIsUnit)~='function' then return nil,'missing-api' end
    local ok,same=pcall(UnitIsUnit,unit,otherunit)
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(same) then return nil,'restricted-value' end
    if same==nil then return nil,'unit-identity-unavailable' end
    if type(same)~='boolean' then return nil,'invalid-api-result' end
    return same

Torna a Riferimento delle funzioni