Riferimento › Riferimento delle funzioni › Platform

Platform.unit_level.GetUnitLevelObservation

pubblica

Chiamala come

addon.Platform:GetUnitLevelObservation(unit)

Disponibile direttamente tramite addon; non serve alcuna dipendenza.

Cosa fa

Osserva il livello grezzo leggibile di un'unità sui client noti. Un'unità leggibile ma assente restituisce exists=false; le unità presenti richiedono un UnitLevel intero, finito e positivo. Livelli dei boss sconosciuti e osservazioni mancanti, fallite, soggette a restrizioni o malformate restituiscono nil con un motivo. Non usa livelli effettivi o scalati.

Argomenti

NomeTipoCosa fa
selfRMPlatformAdattatore di piattaforma di Rotation Master (implicito nelle chiamate con due punti).
unitstringIdentificativo dell'unità di cui osservare il livello grezzo.

Valori restituiti

1table | nilRecord appena letto e leggibile con exists e, se presente, un livello intero positivo.
2string | nilMotivo di indisponibilità o di convalida della query quando l'osservazione del livello è 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
UnitLevelClassic EraTBC AnniversaryClassic progressionForeverRetail
canaccessvalueClassic 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 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.level

Dipendenze

Sorgente

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

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}

Torna a Riferimento delle funzioni