Appel
Conditions.weapon.enchantObservation(value, cache)
Enregistrez la dépendance Conditions.weapon.enchantObservation, 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 whether the main hand, or the off hand when value.offhand is set, has a temporary weapon enchant for the weapon conditions, with its expiration and charges. Uses the cached GetWeaponEnchantInfo or the platform's composed reader.
Arguments
| Nom | Type | Ce qu'elle fait |
|---|---|---|
value | table | Condition settings; a truthy offhand field selects the off hand. |
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
Retours
| 1 | boolean | nil | True when enchanted, false when not, or nil when it cannot be read. |
|---|---|---|
| 2 | number | nil | Time until the enchant expires, as the API reports it; only when enchanted. |
| 3 | number | nil | Charges remaining, as the API reports them; only when enchanted. |
| 4 | string | nil | Reason for nil: missing-api, api-error, restricted-value or invalid-weapon-observation. |
É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
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
- Enchantement d'arme présent (evaluate)
local enchanted, _, _, reason=enchantObservation(value,cache) - Temps restant de l'enchantement d'arme (evaluate)
local enchanted, expires, _, reason=enchantObservation(value,cache) - Cumuls de l'enchantement d'arme (evaluate)
local enchanted, _, charges, reason=enchantObservation(value,cache)
Source
Conditions/weapon.lua, ligne 60. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
Conditions.weapon.enchantObservation(value, cache)
local reader=GetWeaponEnchantInfo
if C_PaperDollInfo and C_PaperDollInfo.GetTemporaryEnchantmentInfo then reader=addon.Platform.ComposedWeaponEnchantInfo end
if type(reader)~="function" then return nil,nil,nil,"missing-api" end
-- The protected cached API returns both hands' original tuple unchanged.
---@diagnostic disable-next-line: unbalanced-assignments
local ok, main, mainExpires, mainCharges, _, off, offExpires, offCharges = pcall(addon.getCached, cache, reader)
if not ok then return nil,nil,nil,"api-error" end
local enchanted, expires, charges=main,mainExpires,mainCharges
if value.offhand then enchanted,expires,charges=off,offExpires,offCharges end
if not addon.Platform:CanReadValue(enchanted) then return nil,nil,nil,"restricted-value" end
if enchanted==nil or enchanted==false or enchanted==0 then return false end
if enchanted~=true and enchanted~=1 then return nil,nil,nil,"invalid-weapon-observation" end
return true,expires,charges




