local AutoFollow = {} _G.AutoFollow = AutoFollow local WaitTimer = LibStub("WaitTimer") AutoFollow.Version = "4.4.2" AutoFollow.TimerID = nil AutoFollow.TimerAQ = nil AutoFollow.Paused = false AutoFollow.HideSound = false AutoFollow.oldPlaySoundByPath = nil AutoFollow.NPC = nil AutoFollow.NPCPosX = nil AutoFollow.NPCPosZ = nil AutoFollowData = {} AutoFollowData.Toggle = false AutoFollowData.ToggleAQ = false AutoFollowData.ID = nil AutoFollowData.Name = nil AutoFollowData.PlayersFollowing = {} local Red = "|H|h|cff9e0000" local Orange = "|H|h|cfff7a804" local Green = "|H|h|cff1ab005" local Blue = "|H|h|cff1b8fa9" AF_AutoQuest = false AF_SendMessages = true AF_SaveLogout = false AF_UseDailyNotes = true AF_IniMode = {} AutoFollowButtonHidden = false function AutoFollow.OnLoad(this) this:RegisterEvent("ZONE_CHANGED"); this:RegisterEvent("CHAT_MSG_PARTY"); this:RegisterEvent("CHAT_MSG_SAY"); this:RegisterEvent("CHAT_MSG_RAID"); this:RegisterEvent("CHAT_MSG_ZONE"); this:RegisterEvent("PARTY_MEMBER_CHANGED"); this:RegisterEvent("PB_RAIDINFO_REFRESH") this:RegisterEvent("VARIABLES_LOADED") this:RegisterEvent("QUEST_COMPLETE") SaveVariablesPerCharacter("AF_AutoQuest") SaveVariablesPerCharacter("AF_IniMode") SaveVariablesPerCharacter("AF_SendMessages") SaveVariablesPerCharacter("AF_SaveLogout") SaveVariablesPerCharacter("AF_UseDailyNotes") SaveVariablesPerCharacter("AutoFollowButtonHidden") SaveVariablesPerCharacter("AutoFollowData") end function AutoFollow.Init() if AF_AutoQuest == nil then AF_AutoQuest = false end if AF_SendMessages == nil then AF_SendMessages = true end if AF_SaveLogout == nil then AF_SaveLogout = false end if AF_UseDailyNotes == nil then AF_UseDailyNotes = true end if AF_IniMode == nil then AF_IniMode = {} end if AutoFollowButtonHidden == nil then AutoFollowButtonHidden = false end table.insert(UnitPopupMenus["SELF"],1,"ToggleAQ") table.insert(UnitPopupMenus["PARTY"],1,"ToggleAF") table.insert(UnitPopupMenus["PARTY"],2,"PauseAF") table.insert(UnitPopupMenus["RAID"],1,"ToggleAF") table.insert(UnitPopupMenus["RAID"],2,"PauseAF") UnitPopupButtons["ToggleAQ"] = {text = Green.."Start|r|h"..Blue.."AutoQuest|r|h"} UnitPopupButtons["ToggleAF"] = {text = Green.."Start|r|h AutoFollow"} UnitPopupButtons["PauseAF"] = {text = Orange.."Pause|r|h AutoFollow"} UnitPopupButtons["StopAF"] = {text = Red.."Stop|r|h AutoFollow"} end function AutoFollow.OnEvent(event, arg1, arg2, arg3, arg4) if event == "VARIABLES_LOADED" then AutoFollow.Init() if AutoFollowButtonHidden then AutoFollow_Button:Hide() end if AutoFollowData.Toggle then if AF_SaveLogout and (GetNumPartyMembers ~= 0 or GetNumRaidMembers() ~= 0) then AutoFollow.Start(true) else AutoFollow.Stop(true) end else AutoFollow.Stop(true) end if AutoFollowData.ToggleAQ then if AF_SaveLogout then AutoFollow.StartAQ() else AutoFollow.StopAQ(true) end else AutoFollow.StopAQ(true) end elseif (event == "CHAT_MSG_PARTY" or event == "CHAT_MSG_SAY" or event == "CHAT_MSG_RAID" or event == "CHAT_MSG_ZONE") then if afpname == nil then while afpname == nil do afpname = UnitName("player") end SendSystemChat("AFDebug: Unit Name found: "..afpname) end if AutoFollowData.Toggle and arg4 == AutoFollowData.Name and (string.find(arg1,"#af(%s+)$") or string.find(arg1,"#af$") or string.find(arg1,"#af(%s+)|H") or string.find(arg1,"#af|H") or string.find(arg1,"#af "..afpname)) then if not AutoFollow.Paused then AutoFollow.Pause() elseif AutoFollow.Paused then AutoFollow.Resume() end else -- SendSystemChat("AFDebug: arg1 -- "..arg1) local SwitchTab = {[Red] = "Off", [Orange] = "Paused", [Green] = "On"} for c, v in pairs(SwitchTab) do -- SendSystemChat("AFDebug: -Autofollow: "..c..v.."|r|h for "..afpname.."-") -- SendSystemChat("AFDebug: c "..c) -- SendSystemChat("AFDebug: v "..v) -- SendSystemChat("AFDebug: ".."|r|h for ") -- SendSystemChat("AFDebug: "..afpname.."-") if string.find(arg1,"AutoFollow: "..c..v.."|r|h for "..afpname) then for r = 1, 36 do if GetRaidMember(r) == arg4 then AutoFollowData.PlayersFollowing[r] = c break end end end end end elseif AutoFollowData.ToggleAQ and AF_AutoQuest and event == "QUEST_COMPLETE" then --if DailyNotes and AF_UseDailyNotes and DN_Char_Options.autoquest and not DailyNotes.SF_IsAnAutoQuest(arg2) then return end WaitTimer.Delay(0.1, function () AutoFollow.StepAQ() end) end if AutoFollowData.Toggle == true or AutoFollow.Paused == true then if event == "ZONE_CHANGED" then if AutoFollow.Paused then return end FollowUnit("raid"..AutoFollowData.ID) if AF_IniMode[GetZoneID()..":"..GetZoneName()] then AutoFollow.Pause() if AF_SendMessages then SendChatMessage("AutoFollow: "..Orange.."Paused|r|h for "..AF_IniMode[GetZoneID()..":"..GetZoneName()] .." seconds after entering "..GetZoneName().." ("..GetZoneID()..").", "PARTY") end WaitTimer.Delay(AF_IniMode[GetZoneID()..":"..GetZoneName()], function () AutoFollow.Resume() end) end elseif event == "PARTY_MEMBER_CHANGED" or event == "PB_RAIDINFO_REFRESH" then if GetRaidMember(AutoFollowData.ID) ~= AutoFollowData.Name then for i = 1,36 do local PName = GetRaidMember(i) if PName == AutoFollowData.Name then AutoFollowData.ID = i if AutoFollow.Paused then AutoFollow.Resume() end return end end --DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: Player left the party/raid", 1, 1, 1) AutoFollow.Pause() elseif AutoFollow.Paused then AutoFollow.Resume() end end end end local hookUnitPopop_ShowMenu = UnitPopop_ShowMenu function UnitPopop_ShowMenu(dropdownMenu, menu, unit, name, userData) if menu == "SELF" then if GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then for i=1,#UnitPopupMenus["SELF"] do if UnitPopupMenus["SELF"][i] == "PauseAF" then table.remove(UnitPopupMenus["SELF"],#UnitPopupMenus["SELF"] - i) break end end else if UnitPopupButtons["PauseAF"].text ~= Orange.. "Pause|r|h AutoFollow (all)" then UnitPopupButtons["PauseAF"].text = Orange.. "Pause|r|h AutoFollow (all)" end for i=1,#UnitPopupMenus["SELF"] do if UnitPopupMenus["SELF"][i] == "PauseAF" then break end if i == #UnitPopupMenus["SELF"] then table.insert(UnitPopupMenus["SELF"],2,"PauseAF") break end end end if AutoFollowData.ToggleAQ then for i=1,#UnitPopupMenus["SELF"] do if UnitPopupMenus["SELF"][i] == "StopAF" then table.remove(UnitPopupMenus["SELF"],i) end end if UnitPopupButtons["ToggleAQ"].text ~= Red.."Stop|r|h"..Blue.." AutoQuest|r|h" then UnitPopupButtons["ToggleAQ"].text = Red.."Stop|r|h"..Blue.." AutoQuest|r|h" end elseif not AutoFollowData.Toggle then local found = false for i=1,#UnitPopupMenus["SELF"] do if UnitPopupMenus["SELF"][i] == "StopAF" then table.remove(UnitPopupMenus["SELF"],i) end if UnitPopupMenus["SELF"][i] == "ToggleAQ" then found = true end if i == #UnitPopupMenus["SELF"] and not found then table.insert(UnitPopupMenus["SELF"],1,"ToggleAQ") break end end if UnitPopupButtons["ToggleAQ"].text ~= Green.."Start|r|h"..Blue.." AutoQuest|r|h" then UnitPopupButtons["ToggleAQ"].text = Green.."Start|r|h"..Blue.." AutoQuest|r|h" end else for i=1,#UnitPopupMenus["SELF"] do if UnitPopupMenus["SELF"][i] == "ToggleAQ" then table.remove(UnitPopupMenus["SELF"],i) end if UnitPopupMenus["SELF"][i] == "StopAF" then break end if i == #UnitPopupMenus["SELF"] then table.insert(UnitPopupMenus["SELF"],1,"StopAF") break end end end elseif menu == "PARTY" or menu == "RAID" then if AutoFollowData.Toggle and UnitRaidIndex(unit) == AutoFollowData.ID and UnitName(unit) == AutoFollowData.Name then if UnitPopupButtons["ToggleAF"].text ~= Red.."Stop|r|h AutoFollow" then UnitPopupButtons["ToggleAF"].text = Red.."Stop|r|h AutoFollow" end else if UnitPopupButtons["ToggleAF"].text ~= Green.."Start|r|h AutoFollow" then UnitPopupButtons["ToggleAF"].text = Green.."Start|r|h AutoFollow" end end if not AutoFollowData.PlayersFollowing[UnitRaidIndex(unit)] then AutoFollowData.PlayersFollowing[UnitRaidIndex(unit)] = Red end UnitPopupButtons["PauseAF"].text = AutoFollowData.PlayersFollowing[UnitRaidIndex(unit)].."Pause|r|h AutoFollow" end hookUnitPopop_ShowMenu(dropdownMenu, menu, unit, name, userData) end local hookUnitPopup_OnClick = UnitPopup_OnClick function UnitPopup_OnClick(this) local dropdownMenu = getglobal(UIDROPDOWNMENU_OPEN_MENU); local button = this.value; local name = dropdownMenu.name; if button == "ToggleAQ" then if AutoFollowData.ToggleAQ then AutoFollow.StopAQ() else AutoFollow.StartAQ() end elseif button == "ToggleAF" then if AutoFollowData.ToggleAQ then AutoFollow.StopAQ() end local OldName = nil if AutoFollowData.Toggle then OldName = AutoFollowData.Name AutoFollow.Stop() end if not OldName or OldName ~= name then for i = 1,36 do if GetRaidMember(i) == name then AutoFollowData.ID = i AutoFollow.Start() break end end end elseif button == "StopAF" then AutoFollow.Stop() elseif button == "PauseAF" then if UIDROPDOWNMENU_OPEN_MENU == "PlayerFrameDropDown" then SendChatMessage("#af","PARTY") else SendChatMessage("#af "..name,"PARTY") end end hookUnitPopup_OnClick(this) end local hookLogout = Logout function Logout() if not AF_SaveLogout then if AutoFollowData.Toggle then AutoFollow.Stop() end if AutoFollowData.ToggleAQ then AutoFollow.StopAQ() end end if AutoFollow.TimerID then WaitTimer.Stop(AutoFollow.TimerID) end if AutoFollow.TimerAQ then WaitTimer.Stop(AutoFollow.TimerAQ) end hookLogout() end local hookSendSystemMsg = SendSystemMsg function SendSystemMsg(msg) if AutoFollowData.Toggle and not AutoFollow.Paused and msg == string.gsub(TEXT("SYS_FOLLOW_END"),"%%s","") then local ActualName = UnitName("target") local NPCfound = false local _,IsOnline = GetRaidMember(AutoFollowData.ID) for i = 1,20 do TargetNearestFriend() if UnitIsNPC("target") then NPCfound = true end if UnitName("target") == ActualName then break end end if NPCfound or not IsOnline then return end MoveForwardStart() WaitTimer.Delay(2.5, function () MoveForwardStop() TurnLeftStart() end) WaitTimer.Delay(4.6, function () TurnLeftStop() end) return elseif AutoFollowData.Toggle and not AutoFollow.Paused and (msg == string.gsub(TEXT("SYS_FOLLOW_END"),"%%s",AutoFollowData.Name) or msg == string.gsub(TEXT("SYS_FOLLOW_BEGIN"),"%%s",AutoFollowData.Name)) then return end hookSendSystemMsg(msg) end local hookPlaySoundByPath = PlaySoundByPath function PlaySoundByPath(Path) if AutoFollow.HideSound then return end hookPlaySoundByPath(Path) end local hookSpeakFrame_Show = SpeakFrame_Show function SpeakFrame_Show() hookSpeakFrame_Show() if GetSpeakObjName() then AutoFollow.NPC = GetSpeakObjName() AutoFollow.NPCPosX, AutoFollow.NPCPosZ = GetPlayerWorldMapPos() end end function AutoFollow.Pause() WaitTimer.Stop(AutoFollow.TimerID) MoveForwardStop() AutoFollow.Paused = true AutoFollow_ButtonOn:Hide() AutoFollow_ButtonPaused:Show() if AF_SendMessages then SendChatMessage("AutoFollow: "..Orange.."Paused|r|h for "..AutoFollowData.Name, "PARTY") end end function AutoFollow.Resume() if not AutoFollowData.Toggle or not AutoFollow.Paused then return end AutoFollow.Paused = false AutoFollow_ButtonPaused:Hide() AutoFollow_ButtonOn:Show() FollowUnit("raid"..AutoFollowData.ID) AutoFollow.TimerID = WaitTimer.Delay(3, function() AutoFollow.Step() return 3 end) if AF_SendMessages then SendChatMessage("AutoFollow: "..Green.."On|r|h for "..AutoFollowData.Name.." (resumed)", "PARTY") end end function AutoFollow.StartAQ() if not AF_AutoQuest then SendSystemMsg("Activate AutoQuest in options first") return end AutoFollow.StepAQ() AutoFollow.TimerAQ = WaitTimer.Delay(3, function() AutoFollow.StepAQ() return 3 end) AutoFollowData.ToggleAQ = true AutoFollow_ButtonAQ:Show() DEFAULT_CHAT_FRAME:AddMessage(Blue.."AutoQuest|r|h"..Green.." started|r|h", 1, 1, 1) end function AutoFollow.StepAQ() if not AF_AutoQuest or not AutoFollowData.ToggleAQ then return end if SpeakFrame:IsVisible() then SendSystemMsg("Please close the dialog for AutoQuest") return end local Px,Pz = GetPlayerWorldMapPos() if not AutoFollow.NPC then return end if not (AutoFollow.NPCPosX - 0.01 < Px and Px < AutoFollow.NPCPosX + 0.01) or not (AutoFollow.NPCPosZ - 0.01 < Pz and Pz < AutoFollow.NPCPosZ + 0.01) then return end --[[local CompletedQuests = {} for i = 1, GetNumQuestBookButton_QuestBook() do local _,_,_,_,_,_,_,_,QID,completed = GetQuestInfo(i) if completed then table.insert(CompletedQuests,QID) end end ]]-- if DailyNotes and AF_UseDailyNotes and DN_Char_Options.autoquest then for i = 1, 3 do for q = 1,GetNumQuest(i) do AutoFollow.HideSound = true DailyNotes.orig_SpeakFrame_LoadQuest() local qname,daily,QuestGroup = GetQuestNameByIndex(i, q) if QuestGroup == 3 then qname = qname .. " [" .. UI_QUEST_MSG_PUBLIC .. "]" elseif daily then qname = qname .. " [" .. UI_QUEST_MSG_DAILY .. "]" end local QID = DailyNotes.FindQuestByName(qname, AutoFollow.NPC) if DailyNotes.SF_IsAnAutoQuest(QID) then OnClick_QuestListButton(i, q) CompleteQuest() OnClick_QuestListButton(i, q) AcceptQuest() end SpeakFrame_Hide() AutoFollow.HideSound = false end end else for i = 1, 3 do for q = 1,GetNumQuest(i) do AutoFollow.HideSound = true OnClick_QuestListButton(i, q) CompleteQuest() OnClick_QuestListButton(i, q) AcceptQuest() SpeakFrame_Hide() AutoFollow.HideSound = false end end end end function AutoFollow.StopAQ(OnLogin) WaitTimer.Stop(AutoFollow.TimerAQ) AutoFollowData.ToggleAQ = false AutoFollow_ButtonAQ:Hide() if not login then DEFAULT_CHAT_FRAME:AddMessage(Blue.."AutoQuest|r|h"..Red.." stopped|r|h", 1, 1, 1) end end function AutoFollow.Start(OnLogin) if OnLogin and GetRaidMember(AutoFollowData.ID) == nil then AutoFollow.Stop() AutoFollow.StopAQ() return end AutoFollowData.Name = GetRaidMember(AutoFollowData.ID) FollowUnit("raid"..AutoFollowData.ID) AutoFollow.TimerID = WaitTimer.Delay(3, function() AutoFollow.Step() return 3 end) AutoFollowData.Toggle = true AutoFollow_ButtonOn:Show() if AF_SendMessages and not OnLogin then SendChatMessage("AutoFollow: "..Green.."On|r|h for "..AutoFollowData.Name, "PARTY") end end function AutoFollow.Step() FollowUnit("raid"..AutoFollowData.ID) AutoFollow.StepAQ() end function AutoFollow.Stop(login) if AF_SendMessages and AutoFollowData.Name and (GetNumPartyMembers() ~= 0 or GetNumRaidMembers() ~= 0) and not login then SendChatMessage("AutoFollow: "..Red.."Off|r|h for "..AutoFollowData.Name, "PARTY") end AutoFollowData.Toggle = false AutoFollowData.ID = nil AutoFollowData.Name = "" AutoFollow.HideSound = false AutoFollow.Paused = false AutoFollow_ButtonOn:Hide() AutoFollow_ButtonPaused:Hide() WaitTimer.Stop(AutoFollow.TimerID) end function AutoFollow.ButtonOnClick(this,key) if not IsShiftKeyDown() then if key == "LBUTTON" then if AutoFollowData.ToggleAQ then AutoFollow.StopAQ() elseif AutoFollowData.Toggle then AutoFollow.Stop() else ToggleDropDownMenu(AutoFollow_MenuStart) end else ToggleDropDownMenu(AutoFollow_Options) end end end function AutoFollow.ButtonOnEnter(this) GameTooltip:SetOwner(this, "ANCHOR_LEFT", 4, 0) GameTooltip:SetText("AutoFollow "..AutoFollow.Version, 1, 1, 1) GameTooltip:AddLine("Right click for options", 0, 0.75, 0.95) GameTooltip:AddLine(UI_MINIMAPBUTTON_MOVE, 0, 0.75, 0.95) GameTooltip:Show() end function AutoFollow.ButtonOnLeave(this) GameTooltip:Hide() end function AutoFollow.MenuOnShow(this) local info = {} info.text = "AutoFollow" info.isTitle = 1 UIDropDownMenu_AddButton( info, 1 ) if this:GetName() == "AutoFollow_MenuStart" then info = {} info.text = Green.."Start|r|h"..Blue.." AutoQuest|r|h" info.func = function() AutoFollow.StartAQ() end UIDropDownMenu_AddButton( info, 1 ) for i = 1,36 do if GetRaidMember(i) and afpname ~= GetRaidMember(i) then info = {} info.text = GetRaidMember(i) info.func = function() AutoFollowData.ID = i AutoFollow.Start() end UIDropDownMenu_AddButton( info, 1 ) end end elseif this:GetName() == "AutoFollow_Options" then info = {} info.text = Orange.."Pause|r|h for other" info.func = function() WaitTimer.Delay(0.001,function() ToggleDropDownMenu(AutoFollow_Pause) end) end info.tooltipTitle = "Pause for other" info.tooltipText = "Pause AutoFollow for player following you" UIDropDownMenu_AddButton( info, 1 ) info = {} info = {} info.text = "Set ini PauseTime" info.func = function() this.AskNumberFrameCallBack = function( button , Number ) AutoFollow.SavePauseTime(Number) end local NameUnimportantLikeTheUniverse = AF_IniMode[GetZoneID()..":"..GetZoneName()] or 0 OpenAskNumberFrame(0,120,this,"TOPLEFT","BOTTOMRIGHT") AskNumberFrame.number = NameUnimportantLikeTheUniverse AskNumberFrameValString:SetText(NameUnimportantLikeTheUniverse) AskNumberFrameLeftButton:Enable() end info.tooltipTitle = "Set ini PauseTime" info.tooltipText = "Automatically pause AutoFollow after entering an instance" UIDropDownMenu_AddButton( info, 1 ) info.text = "AutoQuest" info.checked = AF_AutoQuest info.keepShownOnClick = 1 info.func = function() AF_AutoQuest = not AF_AutoQuest end info.tooltipTitle = "AutoQuest" info.tooltipText = "Note: Only works for the NPC you last talked with" UIDropDownMenu_AddButton( info, 1 ) info = {} info.text = "Messages" info.checked = AF_SendMessages info.keepShownOnClick = 1 info.func = function() AF_SendMessages = not AF_SendMessages end info.tooltipTitle = "Messages" info.tooltipText = "Send messages in group chat when using AutoFollow" UIDropDownMenu_AddButton( info, 1 ) info = {} info.text = "Save on logout" info.checked = AF_SaveLogout info.keepShownOnClick = 1 info.func = function() AF_SaveLogout = not AF_SaveLogout end info.tooltipTitle = "Save on logout" info.tooltipText = "Save toggle status on logout" UIDropDownMenu_AddButton( info, 1 ) info = {} info.text = "Use DailyNotes" info.checked = AF_UseDailyNotes info.keepShownOnClick = 1 info.func = function() AF_UseDailyNotes = not AF_UseDailyNotes end info.tooltipTitle = "Use DailyNotes" info.tooltipText = "Use the DailyNotes addon to use AutoQuest only for marked daily quests" UIDropDownMenu_AddButton( info, 1 ) info = {} info.text = "Hide button" info.func = function() AutoFollowButtonHidden = true AutoFollow_Button:Hide() end info.tooltipTitle = "Hide Button" info.tooltipText = "\"/af button show\" to show it again" UIDropDownMenu_AddButton( info, 1 ) info = {} info.text = "See commands" info.func = function() DEFAULT_CHAT_FRAME:AddMessage("AutoFollow", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af [Party/Raid Number]", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af [Party/Raid Player]", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af aq start", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af aq stop", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af aq", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af ini [seconds to pause]", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af -ini", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af msg", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af button hide", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af button show", 1, 1, 1) end UIDropDownMenu_AddButton( info, 1 ) info = {} info.text = "Report bug / add feature" info.func = function() GC_OpenWebRadio("https://www.curseforge.com/private-messages/send?recipient=Achandos") end info.tooltipTitle = "Contact me" info.tooltipText = "Contact me on curseforge and report a bug or suggest a feature \n AchandosOlymp@gmail.com" UIDropDownMenu_AddButton( info, 1 ) elseif this:GetName() == "AutoFollow_Pause" then info = {} info.text = "All" info.func = function() SendChatMessage("#af","PARTY") end UIDropDownMenu_AddButton( info, 1 ) for i = 1,36 do if GetRaidMember(i) and afpname ~= GetRaidMember(i) then if not AutoFollowData.PlayersFollowing[i] then AutoFollowData.PlayersFollowing[i] = Red end info = {} info.text = AutoFollowData.PlayersFollowing[i]..GetRaidMember(i).."|r|h" info.func = function() SendChatMessage("#af "..GetRaidMember(i),"PARTY") end UIDropDownMenu_AddButton( info, 1 ) end end end end function AutoFollow.SavePauseTime(PauseTime) if not AF_IniMode[GetZoneID()..":"..GetZoneName()] then if PauseTime == 0 then DEFAULT_CHAT_FRAME:AddMessage("AutoFollow does not pause after entering "..GetZoneName().." ("..GetZoneID()..").", 1, 1, 1) return end AF_IniMode[GetZoneID()..":"..GetZoneName()] = PauseTime DEFAULT_CHAT_FRAME:AddMessage("AutoFollow will pause now for "..PauseTime.." seconds after entering " ..GetZoneName().." ("..GetZoneID()..").", 1, 1, 1) else if PauseTime == 0 then AF_IniMode[GetZoneID()..":"..GetZoneName()] = false DEFAULT_CHAT_FRAME:AddMessage("AutoFollow will not pause anymore after entering "..GetZoneName()..".", 1, 1, 1) elseif PauseTime == AF_IniMode[GetZoneID()..":"..GetZoneName()] then DEFAULT_CHAT_FRAME:AddMessage("AutoFollow does pause already for "..PauseTime.." seconds after entering " ..GetZoneName().." ("..GetZoneID()..").", 1, 1, 1) else AF_IniMode[GetZoneID()..":"..GetZoneName()] = PauseTime DEFAULT_CHAT_FRAME:AddMessage("AutoFollow will pause now for "..PauseTime.." seconds after entering " ..GetZoneName().." ("..GetZoneID()..").", 1, 1, 1) end end end local function AutoFollow_SlashCmdHandler(_, msg) if msg == "button hide" then AutoFollowButtonHidden = true AutoFollow_Button:Hide() elseif msg == "button show" then AutoFollowButtonHidden = false AutoFollow_Button:Show() elseif string.find(msg,"ini %d") then AutoFollow.SavePauseTime(msg) elseif string.find(msg,"-ini") then AutoFollow.SavePauseTime(0) elseif msg:lower() == "aq" then AF_AutoQuest = not AF_AutoQuest local AQstate = "" if AF_AutoQuest then AQstate = "on" else AQstate = "off" end DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: AutoQuest turned " ..AQstate, 1, 1, 1) elseif msg:lower() == "msg" then AF_SendMessages = not AF_SendMessages local MSGstate = "" if AF_SendMessages then MSGstate = "on" else MSGstate = "off" end DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: Sending messages turned " ..MSGstate, 1, 1, 1) elseif msg:lower() == "save" then AF_SendMessages = not AF_SendMessages local SaveState = "" if AF_SendMessages then SaveState = "on" else SaveState = "off" end DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: Saving status on logout turned " ..SaveState, 1, 1, 1) elseif msg:lower() == "daily" then AF_UseDailyNotes = not AF_UseDailyNotes local SaveState = "" if AF_UseDailyNotes then SaveState = "on" else SaveState = "off" end DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: Using DailyNotes turned " ..SaveState, 1, 1, 1) elseif msg:lower() == "aq start" then AutoFollow.StartAQ() DEFAULT_CHAT_FRAME:AddMessage(Blue.."AutoQuest|r|h"..Green.." started|r|h", 1, 1, 1) elseif msg:lower() == "aq stop" then AutoFollow.StopAQ() DEFAULT_CHAT_FRAME:AddMessage(Blue.."AutoQuest|r|h"..Red.." stopped|r|h", 1, 1, 1) elseif AutoFollowData.Toggle then AutoFollow.Stop() elseif AutoFollowData.ToggleAQ then AutoFollow.StopAQ() elseif GetNumPartyMembers() == 0 and GetNumRaidMembers() == 0 then DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: Not in a party/raid.", 1, 1, 1) elseif type(tonumber(msg)) == "number" then if not GetRaidMember(tonumber(msg)) then DEFAULT_CHAT_FRAME:AddMessage("AutoFollow: There is no party/raid member in this slot.", 1, 1, 1) return end AutoFollowData.ID = tonumber(msg) AutoFollow.Start() else for i = 1,36 do if msg == GetRaidMember(i) and afpname ~= GetRaidMember(i) then AutoFollowData.ID = i AutoFollow.Start() return end end DEFAULT_CHAT_FRAME:AddMessage("AutoFollow", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af [Party/Raid Number]", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af [Party/Raid Player]", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af aq start", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af aq stop", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af aq", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af ini [seconds to pause]", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af -ini", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af msg", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af button hide", 1, 1, 1) DEFAULT_CHAT_FRAME:AddMessage("/af button show", 1, 1, 1) end end SlashCmdList.af = AutoFollow_SlashCmdHandler _G.SLASH_af1 = "/AutoFollow" _G.SLASH_af2 = "/af"