-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataForAzerothExport.lua
More file actions
78 lines (67 loc) · 2.03 KB
/
Copy pathDataForAzerothExport.lua
File metadata and controls
78 lines (67 loc) · 2.03 KB
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
local FIELDS = {
sourceID = { collectible = true },
illusionID = { collectible = true },
decorID = {},
questID = { itemID = true, mountmodID = true },
recipeID = { itemID = true },
achievementID = {},
factionID = {},
toyID = {},
titleID = {},
mountID = {},
speciesID = {}, -- pets
itemID = {} -- heirlooms
}
-- helper function to lookup field value in parent nodes too
function bubble(table, field)
if table[field] ~= nil then
return table[field]
end
if table.parent then
return bubble(table.parent, field)
end
end
-- helper function to decide which fields to export
function checkfield(category, table, field)
if FIELDS[category][field] then
return table[field]
end
end
-- helper function to only mark false values, leave everything else blank
function iffalse(value)
if value == false then
return false
end
end
SLASH_DFAEXPORT1 = "/dfaexport"
SlashCmdList.DFAEXPORT = function(msg)
if msg == "clear" then
DFA_EXPORT = {}
return
end
-- global variable must be set by ATT code
if not ATT_CURRENT_CACHE then
print("ATT_CURRENT_CACHE not found")
return
end
if msg == "keys" then
for category, _ in pairs(ATT_CURRENT_CACHE) do
print(category)
end
return
end
print("Exporting...")
DFA_EXPORT = {}
for category, _ in pairs(FIELDS) do
DFA_EXPORT[category] = {}
local cache = ATT_CURRENT_CACHE[category]
for id, _ in pairs(cache) do
for idx, item in ipairs(cache[id]) do
--DevTools_Dump(item)
-- TODO Export category name
table.insert(DFA_EXPORT[category], { id = id, itemID = checkfield(category, item, "itemID"), mountmodID = checkfield(category, item, "mountmodID"), u = bubble(item, "u"), b = bubble(item, "b"), rwp = bubble(item, "rwp"), collectible = iffalse(checkfield(category, item, "collectible")) })
end
end
end
print("...done")
end