Riferimento › Riferimento delle funzioni › Platform

Platform.unit_stat.GetUnitStatObservation

pubblica

Chiamala come

addon.Platform:GetUnitStatObservation(unit, stat)

Disponibile direttamente tramite addon; non serve alcuna dipendenza.

Cosa fa

Osserva la statistica effettiva solo dal secondo valore nativo restituito. Sui client con policy di sondaggio o ristretta interroga esattamente UnitExists(unit), poi UnitStat(unit,stat) per i selettori 1..5 o UnitArmor(unit) per il selettore 6. Un'assenza accertata restituisce exists=false; dati richiesti mancanti, falliti, soggetti a restrizioni o non finiti restituiscono nil. Preserva i valori finiti con segno, frazionari e zero; ignora tutti i campi inutilizzati della tupla. L'instradamento 1..6 è una policy dei selettori di RM, non un limite del dominio dei valori nativi.

Argomenti

NomeTipoCosa fa
selfRMPlatformAdattatore di piattaforma di Rotation Master (implicito nelle chiamate con due punti).
unitstringIdentificativo unità selezionato non vuoto, invariato nelle chiamate native.
statnumberSelettore intero di statistica RM da 1 a 5, oppure 6 per l'armatura effettiva.

Valori restituiti

1table | nilRecord con exists=false, oppure exists=true e un valore finito; nil se non disponibile.
2string | nilMotivo di query, di policy o di indisponibilità dell'osservazione.

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
UnitArmorClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitStatClassic 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 armor = addon.Platform:GetUnitStatObservation("player", 6)
if not armor or not armor.exists then return nil end
return armor.value >= 10000

Dipendenze

Sorgente

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

Platform.unit_stat.GetUnitStatObservation(self, unit, stat)
    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(stat) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if not finite(stat) or stat%1~=0 or stat<1 or stat>6 then return nil,'invalid-stat-query' 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
    local fn
    if stat==6 then fn=UnitArmor else fn=UnitStat end
    if type(fn)~='function' then return nil,'missing-api' end
    local ok,_,effective
    if stat==6 then ok,_,effective=pcall(fn,unit)
    else ok,_,effective=pcall(fn,unit,stat) end
    if not ok then return nil,'api-error' end
    if not self:CanReadValue(effective) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(effective) then return nil,'restricted-value' end
    if effective==nil then return nil,'stat-data-unavailable' end
    if not finite(effective) then return nil,'invalid-api-result' end
    return {exists=true,value=effective}

Torna a Riferimento delle funzioni