reset default config if types don't match
This commit is contained in:
parent
b71c4d32ec
commit
411d7a2cce
2 changed files with 16 additions and 1 deletions
|
@ -17,6 +17,19 @@ this.defaultConfig = {
|
|||
|
||||
local currentConfig
|
||||
|
||||
this.resetDefaults = function(config)
|
||||
local resetConfig = {}
|
||||
for k, v in pairs(config) do
|
||||
-- ensure types are consistent, or reset to default
|
||||
if type(v) == type(this.defaultConfig[k]) then
|
||||
resetConfig[k] = config[k]
|
||||
else
|
||||
resetConfig[k] = this.defaultConfig[k]
|
||||
end
|
||||
end
|
||||
return resetConfig
|
||||
end
|
||||
|
||||
this.getConfig = function()
|
||||
currentConfig = currentConfig or mwse.loadConfig(common.configString, this.defaultConfig)
|
||||
return currentConfig
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local config = require("celediel.ASinkingFeeling.config").getConfig()
|
||||
local bigConf = require("celediel.ASinkingFeeling.config")
|
||||
local config = bigConf.getConfig()
|
||||
local common = require("celediel.ASinkingFeeling.common")
|
||||
|
||||
-- Helper Functions
|
||||
|
@ -165,6 +166,7 @@ end
|
|||
|
||||
local function onInitialized()
|
||||
event.register("calcSwimSpeed", sinkInWater)
|
||||
config = bigConf.resetDefaults(config)
|
||||
common.log("Successfully initialized!")
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue