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
| Nome | Tipo | Cosa fa |
|---|---|---|
self | RMPlatform | Adattatore di piattaforma di Rotation Master (implicito nelle chiamate con due punti). |
unit | string | Primo identificativo unità esatto, di cui si verifica l'esistenza prima del confronto. |
otherunit | string | Secondo identificativo unità esatto, passato invariato a UnitIsUnit. |
Valori restituiti
| 1 | boolean | nil | Uguaglianza leggibile tra unità, false se la prima unità è accertata come assente, oppure nil quando le osservazioni richieste non sono disponibili. |
|---|---|---|
| 2 | string | nil | Motivo 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 gioco | |||||
|---|---|---|---|---|---|
UnitExists | |||||
UnitIsUnit |
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 youSorgente
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




