forked from shagu/pfQuest-turtle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatchtable.lua
More file actions
69 lines (59 loc) · 2.24 KB
/
patchtable.lua
File metadata and controls
69 lines (59 loc) · 2.24 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
local loc = GetLocale()
local dbs = { "items", "quests", "quests-itemreq", "objects", "units", "zones", "professions", "areatrigger", "refloot" }
local noloc = { "items", "quests", "objects", "units" }
-- Patch databases to merge TurtleWoW data
local function patchtable(base, diff)
for k, v in pairs(diff) do
if base[k] and type(v) == "table" then
if type(base[k]) == "table" then
patchtable(base[k], v)
else
base[k] = v
end
elseif type(v) == "string" and v == "_" then
base[k] = nil
else
base[k] = v
end
end
end
local loc_core, loc_update
for _, db in pairs(dbs) do
if pfDB[db]["data-turtle"] then
patchtable(pfDB[db]["data"], pfDB[db]["data-turtle"])
end
for loc, _ in pairs(pfDB.locales) do
if pfDB[db][loc] and pfDB[db][loc.."-turtle"] then
loc_update = pfDB[db][loc.."-turtle"] or pfDB[db]["enUS-turtle"]
patchtable(pfDB[db][loc], loc_update)
end
end
end
loc_core = pfDB["professions"][loc] or pfDB["professions"]["enUS"]
loc_update = pfDB["professions"][loc.."-turtle"] or pfDB["professions"]["enUS-turtle"]
if loc_update then patchtable(loc_core, loc_update) end
if pfDB["minimap-turtle"] then patchtable(pfDB["minimap"], pfDB["minimap-turtle"]) end
if pfDB["meta-turtle"] then patchtable(pfDB["meta"], pfDB["meta-turtle"]) end
-- Reload all pfQuest internal database shortcuts
pfDatabase:Reload()
-- Automatically clear quest cache if new turtle quests have been found
local updatecheck = CreateFrame("Frame")
updatecheck:RegisterEvent("PLAYER_ENTERING_WORLD")
updatecheck:SetScript("OnEvent", function()
if pfDB["quests"]["data-turtle"] then
-- count all known turtle-wow quests
local count = 0
for k, v in pairs(pfDB["quests"]["data-turtle"]) do
count = count + 1
end
pfQuest:Debug("TurtleWoW loaded with |cff33ffcc" .. count .. "|r quests.")
-- check if the last count differs to the current amount of quests
if not pfQuest_turtlecount or pfQuest_turtlecount ~= count then
-- remove quest cache to force reinitialisation of all quests.
pfQuest:Debug("New quests found. Reloading |cff33ffccCache|r")
pfQuest_questcache = {}
end
-- write current count to the saved variable
pfQuest_turtlecount = count
end
end)