forked from rando009/ClassicCodex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.lua
106 lines (90 loc) · 3.56 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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 show |cffcccccc - Show database interface")
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 meta <relation> [min, [max]] |cffcccccc - Show related objects on the map")
print("|cff33ffcc/codex|cffffffff clean |cffcccccc - Clean map")
print("|cff33ffcc/codex|cffffffff reset |cffcccccc - Reset map")
print("|cff33ffcc ->|cffffffff Available relations: |cff33ffccchests|r, |cff33ffccherbs|r, |cff33ffccmines|r")
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 == "meta" then
meta["search"] = true
local maps = CodexDatabase:SearchMetaRelation({commandList[2], commandList[3], commandList[4]}, meta)
CodexMap:ShowMapId(CodexDatabase:GetBestMap(maps))
return
end
if arg1 == "clean" then
CodexMap:DeleteNode("CODEX")
CodexMap:UpdateNodes()
return
end
if arg1 == "show" then
if CodexBrowser then CodexBrowser:Show() end
return
end
if arg1 == "reset" then
CodexQuest:ResetAll()
return
end
if type(arg1) == "string" then
if CodexBrowser then
CodexBrowser:Show()
CodexBrowser.input:SetText((string.gsub(string.format("%s %s", arg1, arg2), "^%s*(.-)%s*$", "%1")))
end
return
end
end