Mercurial > wow > lfg-premade-filter
changeset 0:df29f8179b76
initial import
author | ovolkov |
---|---|
date | Wed, 12 Nov 2014 08:48:32 +0300 |
parents | |
children | 0a42898d1dfa |
files | LFGFilter.lua LFGFilter.toc Slash.lua |
diffstat | 3 files changed, 132 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LFGFilter.lua Wed Nov 12 08:48:32 2014 +0300 @@ -0,0 +1,64 @@ +local aName, aEnv = ... +aEnv.LFGFilter_Allow_Activity = {} +aEnv.LFGFilter_Allow_Activity.count = 0 +local LFGFilter_Allow_Activity = aEnv.LFGFilter_Allow_Activity + +function LFGListUtil_SortSearchResults(results) + if LFGFilter_Allow_Activity.count > 0 then + local shift_down = 0 + local original_size = #results + for idx = 1, original_size do + local result = results[idx] + local _, activityID = C_LFGList.GetSearchResultInfo(result) + if LFGFilter_Allow_Activity[activityID] then + if shift_down > 0 then + results[idx - shift_down] = result + end + else + shift_down = shift_down + 1 + end + end + for idx = original_size - shift_down + 1, original_size do + results[idx] = nil + end + end + table.sort(results, LFGListUtil_SortSearchResultsCB); +end + +function LFGListUtil_SortSearchResultsCB(id1, id2) + local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(id1); + local id2, activityID2, name2, comment2, voiceChat2, iLvl2, age2, numBNetFriends2, numCharFriends2, numGuildMates2, isDelisted2 = C_LFGList.GetSearchResultInfo(id2); + + --If one has more friends, do that one first + if ( numBNetFriends1 ~= numBNetFriends2 ) then + return numBNetFriends1 > numBNetFriends2; + end + + if ( numCharFriends1 ~= numCharFriends2 ) then + return numCharFriends1 > numCharFriends2; + end + + if ( numGuildMates1 ~= numGuildMates2 ) then + return numGuildMates1 > numGuildMates2; + end + + if ( activityID1 ~= activityID2 ) then + return activityID1 > activityID2; + end + + --If we aren't sorting by anything else, just go by ID + return id1 < id2; +end + +function LFGPrintRawResults() + local totalResults, results = C_LFGList.GetSearchResults() + for idx = 1, totalResults do + local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(results[idx]) + print(id1, activityID1, C_LFGList.GetActivityInfo(activityID1), '*', name1) + end +end + +-- SoO (Normal): 4 +-- SoO (Heroic): 41 +-- SoO (Mythic): 42 +-- /run LFGFilter_Allow_Activity = { [42] = true } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LFGFilter.toc Wed Nov 12 08:48:32 2014 +0300 @@ -0,0 +1,13 @@ +## Interface: 60000 + +## Title: LFG Filter for Premade Groups +## Version: v1 +## Notes: Sorts premade groups found by raid and difficulty, grouping all similar raids together and allows to filter search results to include only specific raids/difficulties. +## Author: Oleg "Rowaa[SR13]" Volkov + +## OptionalDeps: + +## SavedVariables: + +LFGFilter.lua +Slash.lua \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Slash.lua Wed Nov 12 08:48:32 2014 +0300 @@ -0,0 +1,55 @@ +local aName, aEnv = ... + +local strchar = string.char +local strbyte = string.byte +local random = random +local strsub = strsub +local tonumber = tonumber + +local function UniqSlashID(base, maxNumber) + local clear = true + for idx = 1, maxNumber do + if _G["SLASH_" .. base .. idx] then clear = false break end + end + if SlashCmdList[base] then clear = false end + if clear then return base end + return UniqSlashID(base .. (strchar(random(strbyte('a'), strbyte('z')))), maxNumber) +end + +local slashID + +slashID=UniqSlashID("LFGActivityFilter", 1) +_G["SLASH_" .. slashID .. "1"] = "/lfgaf" +SlashCmdList[slashID] = function(activities) + wipe(aEnv.LFGFilter_Allow_Activity) + local count = 0 + for activity in string.gmatch(activities, "[^ ]+") do + local activity_id = tonumber(activity) + local activity_name + if activity_id then activity_name = C_LFGList.GetActivityInfo(activity_id) end + if activity_name then + print("Adding wanted activity to filter: ", activity_name) + aEnv.LFGFilter_Allow_Activity[activity_id] = true + count = count + 1 + else + print("Can't parse activity ID or it doesn't match known activity: ", activity_id) + end + end + aEnv.LFGFilter_Allow_Activity.count = count + if count > 0 then + print("Activities in filter: ", count) + else + print("Filters removed.") + end +end + +slashID=UniqSlashID("LFGActivityList", 1) +_G["SLASH_" .. slashID .. "1"] = "/lfgal" +SlashCmdList[slashID] = function() + for activity_id = 1, 10000 do + local activity_name = C_LFGList.GetActivityInfo(activity_id) + if activity_name then + print(activity_id, activity_name) + end + end +end \ No newline at end of file