Chiamala come
Conditions.weapon.enchantObservation(value, cache)
Registra la dipendenza Conditions.weapon.enchantObservation, poi chiamala con quel nome. Una chiamata con spazio dei nomi non passa self: usa una chiamata con i due punti o passa tu l'oggetto.
Cosa fa
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.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
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. |
Valori restituiti
| 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. |
Edizioni
Le funzioni di supporto integrate sono registrate su ogni edizione. Ciò che cambia è l'API di gioco che leggono; dove ne manca una, la funzione di supporto ripiega su un'alternativa o restituisce nil con un motivo.
- Non disponibile su quell'edizione (il motivo è nel suggerimento)
- Solo mentre sono attivi i ripieghi di Blizzard per le API deprecate
Valori segreti (Retail e Forever)
Su Retail e Forever il gioco fornisce agli addon valori segreti. Questa funzione di supporto controlla ciò che legge (addon.Platform:CanReadValue) e restituisce nil con un motivo come restricted-value invece di un valore segreto che non può confrontare. Considera nil come non disponibile, non come false.
Come la chiama l'addon
- Incantamento dell'arma presente (evaluate)
local enchanted, _, _, reason=enchantObservation(value,cache) - Tempo rimanente dell'incantamento dell'arma (evaluate)
local enchanted, expires, _, reason=enchantObservation(value,cache) - Accumuli dell'incantamento dell'arma (evaluate)
local enchanted, _, charges, reason=enchantObservation(value,cache)
Sorgente
Conditions/weapon.lua, riga 60. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
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




