Référence › Référence des fonctions › Platform

Platform.glyphs.socket

dépendance

Appel

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

Enregistrez la dépendance Platform.glyphs.socket, puis appelez-la sous ce nom. Un appel par espace de noms ne transmet pas self : utilisez un appel avec deux-points ou passez l'objet vous-même.

Ce qu'elle fait

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

NomTypeCe qu'elle fait
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.

Retours

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

Éditions

Les fonctions utilitaires intégrées sont enregistrées sur toutes les éditions. Ce qui diffère, c'est l'API du jeu qu'elles lisent ; quand l'une manque, la fonction utilitaire se rabat sur une alternative ou renvoie nil avec une raison.

Elle ne lit directement aucune API du jeu.

Valeurs secrètes (Retail et Forever)

Sur Retail et Forever, le jeu transmet aux addons des valeurs secrètes. Cette fonction utilitaire vérifie ce qu'elle lit (addon.Platform:CanReadValue) et renvoie nil avec une raison telle que restricted-value au lieu d'une valeur secrète qu'elle ne peut pas comparer. Traitez nil comme indisponible, pas comme false.

Comment l'addon l'appelle

Dépendances

Source

Platform/glyphs.lua, ligne 71. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.

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}

Retour à Référence des fonctions