This repository was archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoseCore_Settings.lua
More file actions
59 lines (51 loc) · 1.58 KB
/
RoseCore_Settings.lua
File metadata and controls
59 lines (51 loc) · 1.58 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
Rose.Settings = {
moduleName = "Rose.Settings",
}
local self = Rose.Settings
local store = {}
local options = {}
local function log (...)
local message = Rose.Debug.Console.parse(arg)
if(Rose.Debug ~= nil) then
if(Rose.Debug.Console.log ~= nil) then
Rose.Debug.Console.log(message, self.moduleName)
end
end
end
local function logWarning(...)
local message = Rose.Debug.Console.parse(arg)
if(Rose.Debug ~= nil) then
if(Rose.Debug.Console.warning ~= nil) then
Rose.Debug.Console.warning(message, self.moduleName)
end
end
end
function self.getSetting(module, key, default)
if(store[module] == nil) then
store[module] = {}
end
if(store[module][key] == nil and default ~= nil) then
store[module][key] = default
end
return store[module][key]
end
function self.setSetting(module, key, value)
store[module][key] = value
end
function self.loadOptions(moduleName)
if(options[moduleName] ~= nil) then
local moduleOptions = options[moduleName]
return self.parseOptions(moduleOptions)
else
logWarning('Module options not available to be loaded. [moduleName' .. moduleName .. ']')
end
end
function self.onInitialize(_, ...)
log('onInitialize')
end
function self.onACROptions(_, acrModuleName, acrOptions)
options[acrModuleName] = json.decode(acrOptions)
end
RegisterEventHandler("Module.Initalize", self.onInitialize, "Rose.Settings.onInitialize")
-- Custom Events
RegisterEventHandler("Rose.Events.ACROptions", self.onACROptions, "Rose.Settings.onACROptions")