Appel
Core.point_conditions.pointIdentity(self, unit, key)
Enregistrez la dépendance Core.point_conditions.pointIdentity, 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
Observes whether unit exists and, if so, its class, for the point-resource selectors. For the player it reuses a class stored in self.longtermCache under key when it was recorded against the same UnitClass function, and otherwise stores the freshly read class there.
Arguments
| Nom | Type | Ce qu'elle fait |
|---|---|---|
self | RMAddon | Rotation Master addon instance. |
unit | string | Unit token to observe. |
key | any | Long-term cache key for the player's class; only used for "player". The addon passes a private table. |
Retours
| 1 | table | nil | {exists=false}, or {exists=true, class=token}; nil when unavailable. |
|---|---|---|
| 2 | string | nil | The platform observer's reason for nil. |
É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.
- Indisponible sur cette édition (la raison figure dans l'infobulle)
- Uniquement tant que les solutions de repli de Blizzard pour les fonctions obsolètes sont actives
| API du jeu | |||||
|---|---|---|---|---|---|
UnitClass |
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.
Exemple
-- needs the dependency Core.point_conditions.pointIdentity
local record, reason = Functions.cache.getCached(cache, Core.point_conditions.pointIdentity, addon, "target")
if not record then return nil, reason end
return record.exists and record.class == "ROGUE"Source
Core/point_conditions.lua, ligne 27. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
Core.point_conditions.pointIdentity(self, unit, key)
local platform=self.Platform
local nativeClass=UnitClass
local longterm=self.longtermCache
if not platform:CanReadValue(longterm) or type(longterm)~='table' then longterm=nil end
local class
if unit=='player' and longterm and platform:CanReadValue(nativeClass) and type(nativeClass)=='function' then
local entry=rawget(longterm,key)
if platform:CanReadValue(entry) and type(entry)=='table' then
local api,candidate=rawget(entry,'api'),rawget(entry,'class')
if platform:CanReadValue(api) and api==nativeClass and platform:CanReadValue(candidate) and type(candidate)=='string' and candidate~='' then class=candidate end
end
end
local record,reason=platform:GetUnitPointIdentityObservation(unit,class==nil)
if not record then return nil,reason end
if not record.exists then return record end
if class then record.class=class
elseif unit=='player' and longterm and type(nativeClass)=='function' and nativeClass==UnitClass then
rawset(longterm,key,{api=nativeClass,class=record.class})
end
return record




