Call as
Conditions.weapon.enchantObservation(value, cache)
Record the dependency Conditions.weapon.enchantObservation, then call it by that name. A namespaced call does not pass self: use a colon call or pass the object yourself.
What it does
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
| Name | Type | What it does |
|---|---|---|
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. |
Returns
| 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. |
Editions
Built In helpers are registered on every edition. What differs is the game API they read; where one is missing the helper falls back or returns nil with a reason.
- Not available on that edition (the reason is in the tooltip)
- Only while Blizzard's deprecation fallbacks are on
Secret values (Retail and Forever)
On Retail and Forever the game hands addons secret values. This helper checks what it reads (addon.Platform:CanReadValue) and returns nil with a reason such as restricted-value instead of a secret it cannot compare. Treat nil as unavailable, not as false.
How the addon calls it
- Weapon Enchant Present (evaluate)
local enchanted, _, _, reason=enchantObservation(value,cache) - Weapon Enchant Time Remaining (evaluate)
local enchanted, expires, _, reason=enchantObservation(value,cache) - Weapon Enchant Stacks (evaluate)
local enchanted, _, charges, reason=enchantObservation(value,cache)
Source
Conditions/weapon.lua, line 60. Read only in game; Duplicate makes an editable copy.
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




