Referencia › Referencia de funciones › Platform

Platform.glyphs.socket

dependencia

Llamar como

Platform.glyphs.socket(self, fn, index, position)

Registra la dependencia Platform.glyphs.socket 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 one glyph socket by calling fn(index) in protected mode and always returns a slot record with slot=index. The record has active=false when the socket is locked or empty, active=true with spellID when a glyph is present, or a reason (api-error, restricted-value, glyph-socket-unavailable, invalid-api-result) with active left nil.

Argumentos

NombreTipoQué hace
selfRMPlatformRotation Master platform adapter (normally addon.Platform), used for its CanReadValue check.
fnfunctionGetGlyphSocketInfo, called with index as its only argument.
indexnumberGlyph socket index.
positionnumberPosition of the glyph spell ID in the fn result, as returned by layout.

Retornos

1tableSlot record: slot plus active (and spellID), or slot plus reason when unavailable.

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

Dependencias

Código fuente

Platform/glyphs.lua, línea 71. Solo lectura en el juego; Duplicar crea una copia editable.

Platform.glyphs.socket(self, fn, index, position)
    local ok,tuple=pcall(function() return {fn(index)} end)
    if not ok then return {slot=index,reason='api-error'} end
    local enabled,kind,spell=tuple[1],tuple[2],tuple[position]
    if not self:CanReadValue(enabled) or not self:CanReadValue(kind) then return {slot=index,reason='restricted-value'} end
    if enabled==nil and kind==nil then return {slot=index,reason='glyph-socket-unavailable'} end
    if not integer(kind,1) or enabled~=nil and type(enabled)~='boolean' then return {slot=index,reason='invalid-api-result'} end
    if not enabled then return {slot=index,active=false} end
    if not self:CanReadValue(spell) then return {slot=index,reason='restricted-value'} end
    if spell==nil then return {slot=index,active=false} end
    if not integer(spell,1) then return {slot=index,reason='invalid-api-result'} end
    return {slot=index,active=true,spellID=spell}

Volver a Referencia de funciones