Chame como
Platform.glyphs.socket(self, fn, index, position)
Registre a dependência Platform.glyphs.socket e depois chame-a por esse nome. Uma chamada com namespace não passa self: use uma chamada com dois-pontos ou passe o objeto você mesmo.
O que faz
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
| Nome | Tipo | O que faz |
|---|---|---|
self | RMPlatform | Rotation Master platform adapter (normally addon.Platform), used for its CanReadValue check. |
fn | function | GetGlyphSocketInfo, called with index as its only argument. |
index | number | Glyph socket index. |
position | number | Position of the glyph spell ID in the fn result, as returned by layout. |
Retornos
| 1 | table | Slot record: slot plus active (and spellID), or slot plus reason when unavailable. |
|---|
Edições
As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.
Não lê nenhuma API do jogo diretamente.
Valores secretos (Retail e Forever)
No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.
Como o addon a chama
Platform.glyphs.GetGlyphSocketSnapshotlocal record=socket(self,fn,index,position)
Dependências
integer→Platform.glyphs.integer
Código-fonte
Platform/glyphs.lua, linha 71. Somente leitura no jogo; Duplicar cria uma cópia editável.
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}