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:
local f = CreateFrame("Frame");
f:RegisterEvent("CHAT_MSG_WHISPER");
f:RegisterEvent("CHAT_MSG_BN_WHISPER");
function Follower_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("Follower Loaded!", 1.0, 0.0, 0.0, 3.0);
end
f:SetScript("OnEvent", function(self, event, ...)
if(event == "CHAT_MSG_WHISPER" or "CHAT_MSG_BN_WHISPER") then
local arg1, arg2 = ...
if(event == "CHAT_MSG_BN_WHISPER") then -- Yet no function.
end
OnWhisper(arg1, arg2)
end
end)
function OnWhisper(arg1, arg2) -- The whole function seems to be executed twice.
if (arg1 == "f_follow") then
print("Following " .. arg2)
if (CheckInteractDistance(arg2, 4)) then -- This part will not be executed. Instead it goes to the else part.
FollowUnit(arg2)
else
SendChatMessage("I'm too far away to follow you!", "WHISPER", nil, arg2)
end
end
end