-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
37 lines (26 loc) · 929 Bytes
/
main.lua
File metadata and controls
37 lines (26 loc) · 929 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
33
34
35
36
37
require("scripts.customcallbacks")
require("scripts.savehelper")
--create the mod
local mod = RegisterMod("Mod Config Menu (Standalone)", 1)
CustomCallbackHelper.ExtendMod(mod)
MCM = MCM or {}
MCM.StandaloneMod = mod
--add MCM's save to savehelper
SaveHelper.AddMod(mod)
SaveHelper.DefaultGameSave(mod, {
ModConfigSave = false
})
--get and apply the mcm save when savehelper saves and loads data
mod:AddCustomCallback(CustomCallbacks.SH_PRE_MOD_SAVE, function(_, modRef, saveData)
local mcmSave = MCM.GetSave()
saveData.ModConfigSave = mcmSave
end, mod.Name)
mod:AddCustomCallback(CustomCallbacks.SH_POST_MOD_LOAD, function(_, modRef, saveData)
local mcmSave = MCM.LoadSave(saveData.ModConfigSave)
end, mod.Name)
--load mod config menu
require("scripts.modconfig")
if not MCM.StandaloneSaveLoaded then
SaveHelper.Load(MCM.StandaloneMod)
MCM.StandaloneSaveLoaded = true
end