Mercurial > wow > lfg-premade-filter
diff LFGFilter.lua @ 0:df29f8179b76
initial import
author | ovolkov |
---|---|
date | Wed, 12 Nov 2014 08:48:32 +0300 |
parents | |
children | 041bc456db50 |
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