-
Notifications
You must be signed in to change notification settings - Fork 11
/
command.lua
82 lines (69 loc) · 2.64 KB
/
command.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
SLASH_CODEX1, SLASH_CODEX2 = "/codex", "/classiccodex"
SlashCmdList["CODEX"] = function(input, editBox)
local params = {}
local meta = {["addon"] = "CODEX"}
if (input == "" or input == nil) then
print("Classic Codex (v" .. tostring(GetAddOnMetadata("ClassicCodex", "Version")) .. "):")
print("|cff33ffcc/codex|cffffffff unit <unit> |cffcccccc - Search units")
print("|cff33ffcc/codex|cffffffff object <gameObject> |cffcccccc - Search objects")
print("|cff33ffcc/codex|cffffffff item <item> |cffcccccc - Search items")
print("|cff33ffcc/codex|cffffffff vendor <item> |cffcccccc - Search vendors for item")
print("|cff33ffcc/codex|cffffffff quest <questName> |cffcccccc - Show specific quest giver")
print("|cff33ffcc/codex|cffffffff quests |cffcccccc - Show all quests on the map")
print("|cff33ffcc/codex|cffffffff clean |cffcccccc - Clean map")
print("|cff33ffcc/codex|cffffffff reset |cffcccccc - Reset map")
return
end
local commandList = {}
local command
for command in string.gmatch(input, "[^ ]+") do
table.insert(commandList, command)
end
local arg1, arg2 = commandList[1], ""
for i in pairs(commandList) do
if i ~= 1 then
arg2 = arg2 .. commandList[i]
if commandList[i + 1] ~= nil then
arg2 = arg2 .. " "
end
end
end
if arg1 == "unit" then
local maps = CodexDatabase:SearchUnitByName(arg2, meta, "LOWER", true)
CodexMap:ShowMapId(CodexDatabase:GetBestMap(maps))
return
end
if arg1 == "object" then
local maps = CodexDatabase:SearchObjectByName(arg2, meta, "LOWER", true)
CodexMap:ShowMapId(CodexDatabase:GetBestMap(maps))
return
end
if arg1 == "item" then
local maps = CodexDatabase:SearchItemByName(arg2, meta, "LOWER", true)
CodexMap:ShowMapId(CodexDatabase:GetBestMap(maps))
return
end
if arg1 == "vendor" then
local maps = CodexDatabase:SearchVendorByItemName(arg2, meta, true)
CodexMap:ShowMapId(CodexDatabase:GetBestMap(maps))
return
end
if arg1 == "quest" then
local maps = CodexDatabase:SearchQuestByName(arg2, meta, "LOWER", true)
CodexMap:ShowMapId(CodexDatabase:GetBestMap(maps))
return
end
if arg1 == "quests" then
local maps = CodexDatabase:SearchQuests(meta)
CodexMap:UpdateNodes()
return
end
if arg1 == "clean" then
CodexMap:DeleteNode("CODEX")
CodexMap:UpdateNodes()
return
end
if arg1 == "reset" then
CodexQuest:ResetAll()
end
end