add config
This commit is contained in:
parent
ac77b6cb8f
commit
aad9b09935
23
lua/autorun/server/sv_config.lua
Normal file
23
lua/autorun/server/sv_config.lua
Normal file
@ -0,0 +1,23 @@
|
||||
utils = include("sv_utils.lua")
|
||||
config = include("../sh_config.lua")
|
||||
|
||||
local dirs = utils.split(config.config_path, "/")
|
||||
table.remove(dirs)
|
||||
local tmp = "";
|
||||
for i, dir in ipairs(dirs) do
|
||||
tmp = tmp .. dir
|
||||
if not file.Exists(tmp, "DATA")
|
||||
then
|
||||
print(tmp)
|
||||
file.CreateDir(tmp)
|
||||
end
|
||||
tmp = tmp .. "/"
|
||||
end
|
||||
|
||||
if not file.Exists(config.config_path, "DATA")
|
||||
then
|
||||
print(config.config_path)
|
||||
local default_config = {}
|
||||
default_config.diseases = {}
|
||||
file.Write(config.config_path, util.TableToJSON(default_config, true))
|
||||
end
|
11
lua/autorun/server/sv_utils.lua
Normal file
11
lua/autorun/server/sv_utils.lua
Normal file
@ -0,0 +1,11 @@
|
||||
utils = {}
|
||||
|
||||
function utils.split (str, sep)
|
||||
local new_table = {}
|
||||
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
||||
table.insert(new_table, v)
|
||||
end
|
||||
return new_table
|
||||
end
|
||||
|
||||
return utils
|
6
lua/autorun/sh_config.lua
Normal file
6
lua/autorun/sh_config.lua
Normal file
@ -0,0 +1,6 @@
|
||||
config = {}
|
||||
|
||||
-- the config file path location
|
||||
config.config_path = "disease/config.json"
|
||||
|
||||
return config
|
Loading…
Reference in New Issue
Block a user