Referencia › Referencia de funciones › Platform

Platform.unit_identity.GetUnitIdentityObservation

pública

Llamar como

addon.Platform:GetUnitIdentityObservation(unit, otherunit)

Disponible directamente a través de addon; no se necesita ninguna dependencia.

Qué hace

Compara dos tokens de unidad exactos con UnitIsUnit tras comprobar solo el primer token con UnitExists. Si la primera unidad está ausente de forma legible, devuelve false sin comparar. Las observaciones necesarias que faltan, fallan, están restringidas o mal formadas devuelven nil con un motivo. No se agrega una segunda consulta de existencia, búsqueda de GUID ni identidad deducida.

Argumentos

NombreTipoQué hace
selfRMPlatformAdaptador de plataforma de Rotation Master (implícito en las llamadas con dos puntos).
unitstringPrimer token de unidad exacto, cuya existencia se comprueba antes de comparar.
otherunitstringSegundo token de unidad exacto, que se pasa sin cambios a UnitIsUnit.

Retornos

1boolean | nilIgualdad de unidades legible, false si se sabe que la primera unidad está ausente o nil cuando las observaciones necesarias no están disponibles.
2string | nilMotivo de política, validación del token o disponibilidad para un resultado de identidad 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 usa 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 juegoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitIsUnitClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Valores secretos (Retail y Forever)

En Retail y Forever, el juego les entrega a los addons valores secretos. Esta función auxiliar verifica 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

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

Código fuente

Platform/unit_identity.lua, línea 21. Solo lectura en el juego; Duplicar crea una copia editable.

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

Volver a Referencia de funciones