BrokerPack/zz_MiscHelper/core.lua

58 lines
1.6 KiB
Lua

local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local events = {}
local db
local mods = {}
local registered = {}
local inited = {}
child['mhmods'] = child['mhmods'] or {}
LibStub("zzHelper"):Embed(child)
local function prepareDB()
db = addon['db']['profile'][childName]
child['db'] = db
addon['callbacks']:Fire(format("Init%s", childName))
end
local function iterateModuls()
for _, modul in ipairs(child['mhmods']) do
if((child:IsClassic() and not modul['skipClassic']) or not child:IsClassic()) then
mods[#mods + 1] = modul['name']
for _, event in ipairs(modul['events']) do
events[modul['name']] = { [event] = modul['onevent']}
if(not registered[event]) then
registered[event] = true
addon:RegisterFunc(event, "OnEvent", eventHandler)
end
end
-- addon:AddConfigEntry(childName, "toggle",modul['name'],modul['message'],nil,1,nil,nil,nil,nil,options['args'][childName])
child:AddCE(modul['name'],modul['message'])
if(type(modul['init']) == 'function' and db[modul['name']]) then
modul['init']()
inited[modul['name']] = true
end
end
end
end
child['specs'] = {
['name'] = childName,
['sv'] = true,
['cfg'] = true,
['cfgReset'] = prepareDB,
['ldb'] = child['ldb'],
['defaults'] = {
['profile'] = {
[childName] = {
['test'] = false,
['sellgrey'] = true,
['noduel'] = true,
['autorepair'] = false,
['hideclock'] = true,
}
}
}
}
function events:PLAYER_ENTERING_WORLD(_, event)
child:UnregisterEvent(event)
-- iterateModuls()
end
child:NewAddOn(...)