Llamar como
Platform.role.readField(self, object, key)
Registra la dependencia Platform.role.readField y después llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa el objeto tú mismo.
Qué hace
Reads object[key] in protected mode, used to look up optional APIs. Returns the value (possibly nil), or nil with "restricted-value" when the object or the value is secret, "invalid-api-result" when object is not a table, or "api-error" when indexing raises an error.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
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. |
Retornos
| 1 | any | The field value, possibly nil; nil on failure. |
|---|---|---|
| 2 | string | nil | Reason on failure; nil on success. |
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 lee directamente ninguna API del juego.
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.
Cómo la llama el addon
Platform.role.GetInspectRoleObservationlocal namespace,reason=readField(self,_G,'C_SpecializationInfo')Platform.role.GetTalentGroupRoleObservationlocal query,reason=readField(self,_G,'GetTalentGroupRole')
Código fuente
Platform/role.lua, línea 19. Solo lectura en el juego; Duplicar crea una copia editable.
Platform.role.readField(self, object, key)
if not self:CanReadValue(object) then return nil,'restricted-value' end
if type(object)~='table' then return nil,'invalid-api-result' end
local ok,value=pcall(function() return object[key] end)
if not ok then return nil,'api-error' end
if not self:CanReadValue(value) then return nil,'restricted-value' end
return value