Quantcast
Help with if and 'and not' - WoWInterface
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
10-27-16, 02:45 PM   #1
Krainz
An Aku'mai Servant
Join Date: Oct 2016
Posts: 32
Help with if and 'and not'

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:
  1. if UnitAffectingCombat("Player")
  2.                 or InCombatLockdown()
  3.                 or ChatFrame1EditBox:IsShown()
  4.                 or WorldMapFrame:IsShown()
  5.                 or MailFrame:IsShown()
  6.                 or GossipFrame:IsShown()
  7.                 or GameTooltipTextLeft1:GetText()
  8.                 or UnitCastingInfo("Player")
  9.                 or UnitChannelInfo("Player")
  10.                 or UnitExists("Target") then
  11.                     addon:FadeIn();
  12.         end;
and
Lua Code:
  1. addon.timer = 0
  2.         addon:SetScript("OnUpdate", function(self, elapsed)
  3.                 self.timer = self.timer + elapsed
  4.                 local speed = GetUnitSpeed("player");
  5.                 local x, y = GetCursorPosition();
  6.                 if self.x ~= x
  7.                 or self.y ~= y then
  8.                     addon:FadeIn();
  9.                 elseif not IsMouselooking() then
  10.                     self.timer = 0
  11.                     addon:FadeOut();
  12.                 end;
  13.                 if self.timer > 5 then
  14.                     -- check mouse looking here since the cursor position is static while
  15.                     -- holding down right mouse button, also check that you're not mousing
  16.                     -- over a frame since that may not be desirable either
  17.                     if not IsMouselooking() and GetMouseFocus() == WorldFrame then
  18.                         self.x = x
  19.                         self.y = y
  20.                     end
  21.                    
  22.                     self.timer = 0
  23.                 end
  24.         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?
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Help with if and 'and not'

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off