Referencia › Referencia de funciones › Conditions

Conditions.weapon.enchantObservation

dependencia

Llamar como

Conditions.weapon.enchantObservation(value, cache)

Registra la dependencia Conditions.weapon.enchantObservation y luego llámala con ese nombre. Una llamada con espacio de nombres no pasa self: usa una llamada con dos puntos o pasa tú mismo el objeto.

Qué hace

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.

Argumentos

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

Retornos

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.

Ediciones

Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar recurre a una alternativa o devuelve nil con un motivo.

  • No disponible en esa edición (el motivo aparece en la información emergente)
  • Solo mientras estén activas las alternativas de Blizzard para API obsoletas
API del juegoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
C_PaperDollInfo.GetTemporaryEnchantmentInfoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
GetWeaponEnchantInfoClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Valores secretos (Retail y Forever)

En Retail y Forever, el juego entrega a los addons valores secretos. Esta función auxiliar comprueba lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.

Cómo la llama el addon

Código fuente

Conditions/weapon.lua, línea 60. Solo lectura en el juego; Duplicar crea una copia editable.

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

Volver a Referencia de funciones