Reference › Function reference › Platform

Platform.glyphs.socket

dependency

Call as

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

Record the dependency Platform.glyphs.socket, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.

What it does

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.

Arguments

NameTypeWhat it does
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.

Returns

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

Editions

Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.

It reads no game API directly.

Secret values (Retail and Forever)

On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.

How the addon calls it

Dependencies

Source

Platform/glyphs.lua, line 71. Read only in game; Duplicate makes an editable copy.

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}

Back to Function reference