comparison Slash.lua @ 0:df29f8179b76

initial import
author ovolkov
date Wed, 12 Nov 2014 08:48:32 +0300
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:df29f8179b76
1 local aName, aEnv = ...
2
3 local strchar = string.char
4 local strbyte = string.byte
5 local random = random
6 local strsub = strsub
7 local tonumber = tonumber
8
9 local function UniqSlashID(base, maxNumber)
10 local clear = true
11 for idx = 1, maxNumber do
12 if _G["SLASH_" .. base .. idx] then clear = false break end
13 end
14 if SlashCmdList[base] then clear = false end
15 if clear then return base end
16 return UniqSlashID(base .. (strchar(random(strbyte('a'), strbyte('z')))), maxNumber)
17 end
18
19 local slashID
20
21 slashID=UniqSlashID("LFGActivityFilter", 1)
22 _G["SLASH_" .. slashID .. "1"] = "/lfgaf"
23 SlashCmdList[slashID] = function(activities)
24 wipe(aEnv.LFGFilter_Allow_Activity)
25 local count = 0
26 for activity in string.gmatch(activities, "[^ ]+") do
27 local activity_id = tonumber(activity)
28 local activity_name
29 if activity_id then activity_name = C_LFGList.GetActivityInfo(activity_id) end
30 if activity_name then
31 print("Adding wanted activity to filter: ", activity_name)
32 aEnv.LFGFilter_Allow_Activity[activity_id] = true
33 count = count + 1
34 else
35 print("Can't parse activity ID or it doesn't match known activity: ", activity_id)
36 end
37 end
38 aEnv.LFGFilter_Allow_Activity.count = count
39 if count > 0 then
40 print("Activities in filter: ", count)
41 else
42 print("Filters removed.")
43 end
44 end
45
46 slashID=UniqSlashID("LFGActivityList", 1)
47 _G["SLASH_" .. slashID .. "1"] = "/lfgal"
48 SlashCmdList[slashID] = function()
49 for activity_id = 1, 10000 do
50 local activity_name = C_LFGList.GetActivityInfo(activity_id)
51 if activity_name then
52 print(activity_id, activity_name)
53 end
54 end
55 end