Hello,
I'm working on a WeakAura that gives users the option to allow mouseover opacity on a select element. Everything's been going well, but I hit a snag with the mouseover script.
To preface, when the user toggles a mouseover checkbox in the Custom Options tab, it'll update an "isMouseover" variable on the specified element. This part works fine. However, within the "OnEnter" script, when trying to access the "isMouseover" variable, it comes back as nil.
Lua Code:
aura_env.UpdateMouseover = function()
for _,v in pairs(aura_env.config) do
if (v.elementID ~= "" and v.isMouseover) then
local element = _G[v.elementID]
element.isMouseover = v.isMouseover
element.noCombatOpacity = v.noCombatOpacity
element.combatOpacity = v.combatOpacity
element.mouseoverCombatOpacity = v.mouseoverCombatOpacity
element.mouseoverNoCombatOpacity = v.mouseoverNoCombatOpacity
print("Is Mouseover:",self.isMouseover) -- returns true/false
element:SetScript("OnEnter",function(self)
print("Is Mouseover in Script:",self.isMouseover) -- returns nil
if (self.isMouseover) then -- doesn't work
if (UnitAffectingCombat("player")) then
self:SetAlpha(self.mouseoverCombatOpacity)
else
self:SetAlpha(self.mouseoverNoCombatOpacity)
end
end
end)
if (UnitAffectingCombat("player")) then
element:SetAlpha(element.combatOpacity)
else
element:SetAlpha(element.noCombatOpacity)
end
end
end
end
I noticed that even if I run aura_env.UpdateMouseover() at WA_DELAYED_PLAYER_ENTERING_WORLD, element.isMouseover won't exist until I open WeakAuras' options, which I'm assuming means at the time of SetScript(), the .isMouseover variable doesn't exist on the variable yet. I'm not sure how to get around this :/