Справочник › Справочник функций › Platform

Platform.glyphs.socket

зависимость

Как вызывать

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

Запишите зависимость Platform.glyphs.socket и вызывайте её по этому имени. Вызов через пространство имён не передаёт self: используйте вызов через двоеточие или передайте объект сами.

Что делает

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.

Аргументы

ИмяТипЧто делает
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.

Возвращает

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

Издания

Встроенные помощники регистрируются во всех изданиях. Различается игровой API, который они читают; если нужного API нет, помощник использует запасной вариант или возвращает nil с причиной.

Не читает игровой API напрямую.

Секретные значения (Retail и Forever)

В Retail и Forever игра передаёт аддонам секретные значения. Этот помощник проверяет то, что читает (addon.Platform:CanReadValue), и вместо секретного значения, которое нельзя сравнить, возвращает nil с причиной, например restricted-value. Считайте nil недоступным значением, а не ложью.

Как его вызывает аддон

Зависимости

Исходный код

Platform/glyphs.lua, строка 71. В игре только для чтения; «Дублировать» создаёт редактируемую копию.

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}

Назад: Справочник функций