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
| Nom | Type | Ce qu'elle fait |
|---|---|---|
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. |
Retours
| 1 | table | Slot 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
Platform.glyphs.GetGlyphSocketSnapshotlocal record=socket(self,fn,index,position)
Dépendances
integer→Platform.glyphs.integer
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}