Chiamala come
Platform.mobinfo2.readField(self, object, key)
Registra la dipendenza Platform.mobinfo2.readField, poi chiamala con quel nome. Una chiamata con spazio dei nomi non passa self: usa una chiamata con i due punti o passa tu l'oggetto.
Cosa fa
Reads object[key] in protected mode for MobInfo2 data. Returns the value (possibly nil), or nil with "restricted-value" when the object or the value is secret, "invalid-mobinfo2-data" when object is not a table, or "mobinfo2-data-error" when indexing raises an error.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (normally addon.Platform), used for its CanReadValue check. |
object | table | Table to index; any other type is rejected. |
key | any | Field name to read. |
Valori restituiti
| 1 | any | The field value, possibly nil; nil on failure. |
|---|---|---|
| 2 | string | nil | Reason on failure; nil on success. |
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 legge direttamente alcuna API di gioco.
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.
Come la chiama l'addon
Platform.mobinfo2.GetMobInfo2Observationlocal query,queryReason=readField(self,_G,'MI2_GetMobData')Platform.mobinfo2.hitCountlocal hits,reason=readField(self,resists,school..'Hits')
Sorgente
Platform/mobinfo2.lua, riga 29. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
Platform.mobinfo2.readField(self, object, key)
if not self:CanReadValue(object) then return nil,'restricted-value' end
if type(object)~='table' then return nil,'invalid-mobinfo2-data' end
local ok,value=pcall(function() return object[key] end)
if not ok then return nil,'mobinfo2-data-error' end
if not self:CanReadValue(value) then return nil,'restricted-value' end
return value