-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
32 lines (27 loc) · 793 Bytes
/
Core.lua
File metadata and controls
32 lines (27 loc) · 793 Bytes
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
local Libra = LibStub("Libra")
local LDB = LibStub("LibDataBroker-1.1")
local addon = Libra:NewAddon(...)
Libra:Embed(addon)
function addon:OnInitialize()
Broker_EssentialsDB = Broker_EssentialsDB or {}
end
local function copyDefaults(source, target)
source = source or { }
target = target or { }
for k, v in pairs(source) do
if type(v) == "table" then
target[k] = copyDefaults(v, target[k])
elseif type(v) ~= type(target[k]) then
target[k] = v
end
end
return target
end
local function getDB(self, defaults)
Broker_EssentialsDB[self.name] = copyDefaults(defaults, Broker_EssentialsDB[self.name])
return Broker_EssentialsDB[self.name]
end
function addon:OnModuleCreated(name, data)
LDB:NewDataObject(name, data)
data.GetDB = getDB
end