Public API - 0xbs/premade-groups-filter GitHub Wiki

Macro to set advanced expression

API

  • PremadeGroupsFilter.Macro(expression, sorting)
    • string expression is your custom filtering expression
    • optional string sorting is your custom sorting expression

Example

Macro example 1:

/run PremadeGroupsFilter.Macro("mprating >= 1000 and not declined")

Macro example 2 with sorting:

/run PremadeGroupsFilter.Macro("tanks + heals > 0", "age asc")

Overwrite sorting function

API

  • PremadeGroupsFilter.OverwriteSortSearchResults(addonName, customSortingFunction)
    • string addonName is the name of your addon
    • function customSortingFunction is a function that takes the results table (containing a list of search result IDs) and sorts it in place
  • PremadeGroupsFilter.RestoreSortSearchResults(addonName)
    • string addonName is the name of your addon

Example

local addonName, addon = ...

local customSortingFunction = function(results)
    table.sort(results, function(resultID1, resultID2)
        local info1 = C_LFGList.GetSearchResultInfo(resultID1)
        local info2 = C_LFGList.GetSearchResultInfo(resultID2)
        return info1.age > info2.age -- by age oldest to newest
    end)
end

local frame = CreateFrame("Frame", addonName .. "EventFrame")
frame:RegisterEvent("ADDON_LOADED")
frame:SetScript("OnEvent", function(self, event, ...)
    if event == "ADDON_LOADED" and select(1, ...) == addonName then
        print("Overwriting sorting function of PremadeGroupsFilter")
        PremadeGroupsFilter.OverwriteSortSearchResults(addonName, customSortingFunction)
        --PremadeGroupsFilter.RestoreSortSearchResults(addonName)
    end
end)

Debug logging

API

  • PremadeGroupsFilter.EnableDebugLogging()

Example

Type into chat window:

/run PremadeGroupsFilter.EnableDebugLogging()