Appel
Conditions.spatial_stats.observation(cache, method, unit, power)
Enregistrez la dépendance Conditions.spatial_stats.observation, 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 health or mana number for a PROXIMITY_* condition through the evaluation cache, protected against errors. With power set it passes Enum.PowerType.Mana as the second argument; restricted, negative, NaN or infinite readings are rejected.
Arguments
| Nom | Type | Ce qu'elle fait |
|---|---|---|
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
method | function | API to call, such as UnitHealth or UnitPowerMax. |
unit | string | Unit token to read. |
power | boolean | nil | Truthy to read mana. |
Retours
| 1 | number | nil | The reading, or nil when unavailable. |
|---|---|---|
| 2 | string | nil | Reason for nil: missing-api, api-error, restricted-value or statistic-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.
- 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 | |||||
|---|---|---|---|---|---|
Enum.PowerType |
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
Conditions.spatial_stats.statisticlocal current,reason=observation(cache,method,unit,mana)
Source
Conditions/spatial_stats.lua, ligne 60. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
Conditions.spatial_stats.observation(cache, method, unit, power)
if type(method)~="function" then return nil,"missing-api" end
local ok,current
if power then ok,current=pcall(addon.getCached,cache,method,unit,Enum.PowerType.Mana)
else ok,current=pcall(addon.getCached,cache,method,unit) end
if not ok then return nil,"api-error" end
if not addon.Platform:CanReadValue(current) then return nil,"restricted-value" end
if type(current)~="number" or current~=current or current<0 or current==math.huge then return nil,"statistic-unavailable" end
return current




