Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/customScripts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[

]
2 changes: 2 additions & 0 deletions scripts/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions scripts/serverCore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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", {})
Expand Down Expand Up @@ -275,6 +292,7 @@ function OnServerPostInit()
end

tes3mp.SetRuleString("respawnCell", respawnCell)
LoadScriptsFromJson(config.customScriptsPath)
end
customEventHooks.triggerHandlers("OnServerPostInit", eventStatus, {})
end
Expand Down