diff --git a/data/customScripts.json b/data/customScripts.json new file mode 100644 index 00000000..1610ea14 --- /dev/null +++ b/data/customScripts.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/scripts/config.lua b/scripts/config.lua index 56f0e5b8..75dae2df 100644 --- a/scripts/config.lua +++ b/scripts/config.lua @@ -462,5 +462,7 @@ config.recordstoreKeyOrder = { "general", "permanentRecords", "generatedRecords" config.worldKeyOrder = { "general", "time", "topics", "kills", "journal", "customVariables", "type", "index", "quest", "actorRefId", "year", "month", "day", "hour", "daysPassed", "timeScale" } + +config.customScriptsPath = "customScripts.json" return config diff --git a/scripts/serverCore.lua b/scripts/serverCore.lua index c9da7425..db99016e 100644 --- a/scripts/serverCore.lua +++ b/scripts/serverCore.lua @@ -207,6 +207,23 @@ function OnServerInit() customEventHooks.triggerHandlers("OnServerInit", eventStatus, {}) end +function LoadScriptsFromJson(filename) + local scripts = jsonInterface.load(filename) + tableHelper.fixNumericalKeys(scripts, true) + + if scripts == nil then + tes3mp.LogMessage(enumerations.log.ERROR, "Script file list " .. filename .. " cannot be read!") + tes3mp.StopServer(2) + else + for index,script in ipairs(scripts) do + for name,file in pairs(script) do + require(file) + tes3mp.LogMessage(enumerations.log.INFO, "Loaded script "..name) + end + end + end +end + function OnServerPostInit() tes3mp.LogMessage(enumerations.log.INFO, "Called \"OnServerPostInit\"") local eventStatus = customEventHooks.triggerValidators("OnServerPostInit", {}) @@ -275,6 +292,7 @@ function OnServerPostInit() end tes3mp.SetRuleString("respawnCell", respawnCell) + LoadScriptsFromJson(config.customScriptsPath) end customEventHooks.triggerHandlers("OnServerPostInit", eventStatus, {}) end