Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-07-14, 12:29 PM   #1
Tuetenpenner
A Defias Bandit
Join Date: Nov 2014
Posts: 2
If(...) will not be executed.

This is my first Addon and I need some Help. The if() which includes the function FollowUnit() will not be executed. Also my OnWhisper() function seems to be executed twice.

Lua Code:
  1. local f = CreateFrame("Frame");
  2. f:RegisterEvent("CHAT_MSG_WHISPER");
  3. f:RegisterEvent("CHAT_MSG_BN_WHISPER");
  4.  
  5. function Follower_OnLoad()
  6.     DEFAULT_CHAT_FRAME:AddMessage("Follower Loaded!", 1.0, 0.0, 0.0, 3.0);
  7. end
  8.  
  9. f:SetScript("OnEvent", function(self, event, ...)
  10.     if(event == "CHAT_MSG_WHISPER" or "CHAT_MSG_BN_WHISPER") then
  11.         local arg1, arg2 = ...
  12.  
  13.             if(event == "CHAT_MSG_BN_WHISPER") then -- Yet no function.
  14.  
  15.             end
  16.  
  17.             OnWhisper(arg1, arg2)
  18.     end
  19. end)
  20.  
  21. function OnWhisper(arg1, arg2) -- The whole function seems to be executed twice.
  22.     if (arg1 == "f_follow") then
  23.         print("Following " .. arg2)
  24.  
  25.             if (CheckInteractDistance(arg2, 4)) then -- This part will not be executed. Instead it goes to the else part.
  26.                 FollowUnit(arg2)
  27.             else
  28.                 SendChatMessage("I'm too far away to follow you!", "WHISPER", nil, arg2)
  29.             end
  30.     end
  31. end

Last edited by Tuetenpenner : 11-07-14 at 12:33 PM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » If(...) will not be executed.


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