Appel
Conditions.build.imbueObservation(value, cache)
Enregistrez la dépendance Conditions.build.imbueObservation, 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 the temporary enchant ID on the main hand, or the off hand when value.offhand is set, for the WEAPON_IMBUE condition. Uses the cached GetWeaponEnchantInfo, or the platform's composed reader on clients with C_PaperDollInfo.GetTemporaryEnchantmentInfo, and returns false when that hand has no temporary enchant.
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 | number | boolean | nil | Enchant ID of the temporary enchant, false when the hand has none, or nil when it cannot be read. |
|---|---|---|
| 2 | 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
- Type d'enchantement d'arme (evaluate)
local id, reason = imbueObservation(value, cache)
Dépendances
Functions.cache.getCached→Functions.cache.getCachedFunctions.presentation.nullable→Functions.presentation.nullableFunctions.values.compare→Functions.values.compareFunctions.values.isin→Functions.values.isin
Source
Conditions/build.lua, ligne 88. En lecture seule dans le jeu ; Dupliquer crée une copie modifiable.
Conditions.build.imbueObservation(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, "missing-api" end
---@diagnostic disable-next-line: unbalanced-assignments
local ok, main, _, _, mainID, off, _, _, offID = pcall(Functions.cache.getCached, cache, reader)
if not ok then return nil, "api-error" end
local enchanted, id = main, mainID
if value.offhand then enchanted, id = off, offID end
if not addon.Platform:CanReadValue(enchanted) or not addon.Platform:CanReadValue(id) then return nil, "restricted-value" end
if enchanted == nil or enchanted == false or enchanted == 0 then return false end
if type(id) ~= "number" then return nil, "invalid-weapon-observation" end
return id




