Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ChokoTools.SearchResults = {}
- ChokoTools.FilteredIDs = {}
- ChokoTools.HopFSM = "Search"
- --Standard Basic Button
- ChokoTools.RandHop = CreateFrame("Button",nil,UIParent)
- ChokoTools.RandHop:SetSize(50,18)
- ChokoTools.RandHop:SetPoint("BOTTOMLEFT",0,0)
- ChokoTools.RandHop:SetText("HOP")
- ChokoTools.RandHop:RegisterEvent("LFG_LIST_SEARCH_RESULTS_RECEIVED")
- ChokoTools.RandHop:RegisterEvent("LFG_LIST_SEARCH_FAILED")
- ChokoTools.RandHop.bg = ChokoTools.RandHop:CreateTexture("ARTWORK")
- ChokoTools.RandHop.bg:SetColorTexture(0.2,0.2,0.2,1)
- ChokoTools.RandHop.bg:SetAllPoints(ChokoTools.RandHop)
- ChokoTools.RandHop.txt = ChokoTools.RandHop:CreateFontString(nil,"ARTWORK")
- ChokoTools.RandHop.txt:SetFont("Interface\\AddOns\\ChokoTools\\fonts\\Exo2.ttf", 12)
- ChokoTools.RandHop.txt:SetTextColor(0.8,0.8,0.8)
- ChokoTools.RandHop.txt:SetText("HOP")
- ChokoTools.RandHop.txt:SetPoint("CENTER")
- ChokoTools.RandHop:SetScript("OnClick", function(self, event, ...)
- if IsInGroup() or IsInRaid() then
- LeaveParty()
- ChokoTools.SearchResults = {}
- ChokoTools.FilteredIDs = {}
- ChokoTools.HopFSM = "Search"
- ChokoTools.RandHop.txt:SetText("HOP")
- return
- end
- ChokoTools:RandomGroup()
- end)
- ChokoTools.RandHop:SetScript("OnEvent", function(self, event, ...)
- if event == "LFG_LIST_SEARCH_RESULTS_RECEIVED" then
- --Get Search Results
- c, ChokoTools.SearchResults = C_LFGList.GetSearchResults()
- --Iterate through search results
- for i=1,#ChokoTools.SearchResults do
- local id, _, _, _, _, _, _, _, _, _, _, _, _, _, autoinv = C_LFGList.GetSearchResultInfo(ChokoTools.SearchResults[i])
- if autoinv == true then
- table.insert(ChokoTools.FilteredIDs,id)
- end
- end
- ChokoTools.HopFSM = "Join"
- ChokoTools.RandHop.txt:SetText("JOIN")
- elseif event == "LFG_LIST_SEARCH_FAILED" then
- ChokoTools.SearchResults = {}
- ChokoTools.FilteredIDs = {}
- ChokoTools.HopFSM = "Search"
- end
- end)
- --Function: Search for groups with Auto Accept on. Join if we have data.
- function ChokoTools:RandomGroup()
- if ChokoTools.HopFSM == "Join" then
- if (ChokoTools.FilteredIDs) and (#ChokoTools.FilteredIDs >= 1) then
- print("Joining...")
- C_LFGList.ApplyToGroup(ChokoTools.FilteredIDs[1], "", false, false, true)
- ChokoTools.FilteredIDs = {} --Reset table to empty
- end
- end
- if ChokoTools.HopFSM == "Search" then
- print("Searching...")
- ChokoTools.SearchResults = {}
- ChokoTools.FilteredIDs = {}
- --Search Groups (Taken and modified from "ServerHop" Addon)
- local lang = {}
- for k,v in pairs(C_LFGList.GetAvailableLanguageSearchFilter()) do lang[v]=true end
- C_LFGList.Search(6,LFGListSearchPanel_ParseSearchTerms(""),0,0,lang) --Search "Custom" groups
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement