Mercurial > wow > lfg-premade-filter
comparison LFGFilter.lua @ 0:df29f8179b76
initial import
| author | ovolkov |
|---|---|
| date | Wed, 12 Nov 2014 08:48:32 +0300 |
| parents | |
| children | 041bc456db50 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:df29f8179b76 |
|---|---|
| 1 local aName, aEnv = ... | |
| 2 aEnv.LFGFilter_Allow_Activity = {} | |
| 3 aEnv.LFGFilter_Allow_Activity.count = 0 | |
| 4 local LFGFilter_Allow_Activity = aEnv.LFGFilter_Allow_Activity | |
| 5 | |
| 6 function LFGListUtil_SortSearchResults(results) | |
| 7 if LFGFilter_Allow_Activity.count > 0 then | |
| 8 local shift_down = 0 | |
| 9 local original_size = #results | |
| 10 for idx = 1, original_size do | |
| 11 local result = results[idx] | |
| 12 local _, activityID = C_LFGList.GetSearchResultInfo(result) | |
| 13 if LFGFilter_Allow_Activity[activityID] then | |
| 14 if shift_down > 0 then | |
| 15 results[idx - shift_down] = result | |
| 16 end | |
| 17 else | |
| 18 shift_down = shift_down + 1 | |
| 19 end | |
| 20 end | |
| 21 for idx = original_size - shift_down + 1, original_size do | |
| 22 results[idx] = nil | |
| 23 end | |
| 24 end | |
| 25 table.sort(results, LFGListUtil_SortSearchResultsCB); | |
| 26 end | |
| 27 | |
| 28 function LFGListUtil_SortSearchResultsCB(id1, id2) | |
| 29 local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(id1); | |
| 30 local id2, activityID2, name2, comment2, voiceChat2, iLvl2, age2, numBNetFriends2, numCharFriends2, numGuildMates2, isDelisted2 = C_LFGList.GetSearchResultInfo(id2); | |
| 31 | |
| 32 --If one has more friends, do that one first | |
| 33 if ( numBNetFriends1 ~= numBNetFriends2 ) then | |
| 34 return numBNetFriends1 > numBNetFriends2; | |
| 35 end | |
| 36 | |
| 37 if ( numCharFriends1 ~= numCharFriends2 ) then | |
| 38 return numCharFriends1 > numCharFriends2; | |
| 39 end | |
| 40 | |
| 41 if ( numGuildMates1 ~= numGuildMates2 ) then | |
| 42 return numGuildMates1 > numGuildMates2; | |
| 43 end | |
| 44 | |
| 45 if ( activityID1 ~= activityID2 ) then | |
| 46 return activityID1 > activityID2; | |
| 47 end | |
| 48 | |
| 49 --If we aren't sorting by anything else, just go by ID | |
| 50 return id1 < id2; | |
| 51 end | |
| 52 | |
| 53 function LFGPrintRawResults() | |
| 54 local totalResults, results = C_LFGList.GetSearchResults() | |
| 55 for idx = 1, totalResults do | |
| 56 local id1, activityID1, name1, comment1, voiceChat1, iLvl1, age1, numBNetFriends1, numCharFriends1, numGuildMates1, isDelisted1 = C_LFGList.GetSearchResultInfo(results[idx]) | |
| 57 print(id1, activityID1, C_LFGList.GetActivityInfo(activityID1), '*', name1) | |
| 58 end | |
| 59 end | |
| 60 | |
| 61 -- SoO (Normal): 4 | |
| 62 -- SoO (Heroic): 41 | |
| 63 -- SoO (Mythic): 42 | |
| 64 -- /run LFGFilter_Allow_Activity = { [42] = true } |
