Mercurial > wow > lfg-premade-filter
view Slash.lua @ 4:d88ea0fdc19c
Added tag v2 for changeset 041bc456db50
author | ovolkov |
---|---|
date | Wed, 21 Jan 2015 19:19:13 +0300 |
parents | df29f8179b76 |
children |
line wrap: on
line source
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