Reference › Function reference › Conditions

Conditions.weapon.enchantObservation

dependency

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

NameTypeWhat it does
valuetableCondition settings; a truthy offhand field selects the off hand.
cachetable | nilEvaluation-pass cache passed to getCached, or nil to read directly.

Returns

1boolean | nilTrue when enchanted, false when not, or nil when it cannot be read.
2number | nilTime until the enchant expires, as the API reports it; only when enchanted.
3number | nilCharges remaining, as the API reports them; only when enchanted.
4string | nilReason 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
Game APIClassic EraTBC AnniversaryClassic progressionForeverRetail
C_PaperDollInfo.GetTemporaryEnchantmentInfoClassic EraTBC AnniversaryClassic progressionForeverRetail
GetWeaponEnchantInfoClassic EraTBC AnniversaryClassic progressionForeverRetail

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

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

Back to Function reference