I had this other thread in the addon help section but it evolved to be more of a LUA problem so I'm posting it in here
Hi, I'm having trouble understanding the logic within 'if not' and 'and' in the same statement. Does that mean 'if not' AND 'if and not' or 'if not' AND 'if true'?
I need to understand that to merge these two codes:
Lua Code:
if UnitAffectingCombat("Player")
or InCombatLockdown()
or ChatFrame1EditBox:IsShown()
or WorldMapFrame:IsShown()
or MailFrame:IsShown()
or GossipFrame:IsShown()
or GameTooltipTextLeft1:GetText()
or UnitCastingInfo("Player")
or UnitChannelInfo("Player")
or UnitExists("Target") then
addon:FadeIn();
end;
and
Lua Code:
addon.timer = 0
addon:SetScript("OnUpdate", function(self, elapsed)
self.timer = self.timer + elapsed
local speed = GetUnitSpeed("player");
local x, y = GetCursorPosition();
if self.x ~= x
or self.y ~= y then
addon:FadeIn();
elseif not IsMouselooking() then
self.timer = 0
addon:FadeOut();
end;
if self.timer > 5 then
-- check mouse looking here since the cursor position is static while
-- holding down right mouse button, also check that you're not mousing
-- over a frame since that may not be desirable either
if not IsMouselooking() and GetMouseFocus() == WorldFrame then
self.x = x
self.y = y
end
self.timer = 0
end
end)
Putting unitaffectingcombat, incombatlockdown, and the likes together with 'self.x ~= x or self.y ~= y'
seems to be a good implementation, but it isn't proper. The big chunk of if situations (the first code) must be together with 'not ismouselooking() and getmousefocus() == worldframe' because these in these two situations the mouse will be standing still and it's the same for all the situations in the first big chunk of code.
How do I do that? I tried just pasting everything after worldframe with lots of 'or's, didn't work, then changed all of them to 'and', which didn't work and ultimately changed to 'and not', and also didn't work.
What to do?