forked from thisdp/dgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigLoad.lua
38 lines (37 loc) · 1.26 KB
/
configLoad.lua
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
38
dgsConfig = {}
dgsConfig.updateCheckAuto = true -- Enable:true;Disable:false
dgsConfig.updateCheckInterval = 60 -- Minutes
dgsConfig.updateCheckNoticeInterval = 5 -- Minutes
dgsConfig.backup = true -- Whether to make a backup for current dgs before updating
dgsConfig.backupMax = 10 -- How many backup can dgs store in maximum.
function loadConfig()
outputDebugString("[DGS]Loading Config File...")
if fileExists("config.txt") then
local file = fileOpen("config.txt")
if file then
local str = fileRead(file,fileGetSize(file))
fileClose(file)
local fnc = loadstring(str)
if fnc then
fnc()
outputDebugString("[DGS]Config File Loaded!")
else
outputDebugString("[DGS]Config File is invaild!",2)
end
else
outputDebugString("[DGS]Config File is unavailable!",2)
end
else
outputDebugString("[DGS]Config File is not exists! Creating...")
local file = fileCreate("config.txt")
local str = ""
for k,v in pairs(dgsConfig) do
local value = type(v) == "string" and '"'..v..'"' or tostring(v)
str = str..string.char(13)..string.char(10).."dgsConfig."..k.." = "..value
end
fileWrite(file,str:sub(3))
fileClose(file)
outputDebugString("[DGS]Config File Created!")
end
end
loadConfig()