Llamar como
addon.Platform:GetUnitLevelObservation(unit)
Disponible directamente a través de addon; no hace falta ninguna dependencia.
Qué hace
Observa un nivel de unidad en bruto legible en clientes conocidos. Una unidad ausente legible devuelve exists=false; las unidades presentes requieren un UnitLevel entero positivo y finito. Los niveles de jefe desconocidos y las observaciones que faltan, fallan, están restringidas o mal formadas devuelven nil con un motivo. No usa niveles efectivos ni escalados.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
self | RMPlatform | Adaptador de plataforma de Rotation Master (implícito en las llamadas con dos puntos). |
unit | string | Token de unidad cuyo nivel en bruto se debe observar. |
Retornos
| 1 | table | nil | Registro nuevo y legible con exists y, si está presente, un nivel entero positivo. |
|---|---|---|
| 2 | string | nil | Motivo de disponibilidad o de validación de la consulta para una observación de nivel 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 recurre a 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 juego | |||||
|---|---|---|---|---|---|
UnitExists | |||||
UnitLevel | |||||
canaccessvalue |
Valores secretos (Retail y Forever)
En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba 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 target = addon.Platform:GetUnitLevelObservation("target")
local player = addon.Platform:GetUnitLevelObservation("player")
if not target or not player or not player.exists then return nil end
return target.exists and target.level < player.levelDependencias
finite→Platform.unit_level.finite
Código fuente
Platform/unit_level.lua, línea 28. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.unit_level.GetUnitLevelObservation(self, unit)
if not self:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if self:GetClientFamily()=='unknown' then return nil,'unsupported-client' 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 {exists=false} end
if type(UnitLevel)~='function' then return nil,'missing-api' end
local levelOk,level=pcall(UnitLevel,unit)
if not levelOk then return nil,'api-error' end
if not self:CanReadValue(level) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(level) then return nil,'restricted-value' end
if level==nil then return nil,'level-data-unavailable' end
if not finite(level) then return nil,'invalid-api-result' end
if level<0 then return nil,'level-data-unavailable' end
if level==0 or level%1~=0 then return nil,'invalid-api-result' end
return {exists=true,level=level}




