DESKTOP-B25GA9E\W35
1 year ago
8 changed files with 81 additions and 11 deletions
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
Files = file.list(); |
||||
if Files["Config.lua"] then |
||||
dofile("Config.lua"); |
||||
end |
||||
--Get data from config files |
||||
function GetData(key) |
||||
if Config_Table[key] ~=nil then |
||||
return Config_Table[key]; |
||||
end |
||||
return nil; |
||||
end |
||||
|
||||
--Save data to config files |
||||
function SaveData(key,value) |
||||
file.open("Config.lua", "w+") |
||||
|
||||
Config_Table[key] = value; |
||||
local tableStr = TableToStr(Config_Table); |
||||
file.write(tableStr); |
||||
file.close() |
||||
end |
||||
|
||||
function TableToStr(table) |
||||
local stringData = "{\n" |
||||
for key, value in pairs(table) do |
||||
local keyValue = "[\"" .. tostring(key) .. "\"]=" |
||||
local valueString = "\"" .. tostring(value) .. "\"" |
||||
stringData = stringData .. " " .. keyValue .. valueString .. ",\n" |
||||
end |
||||
stringData = stringData:sub(1, #stringData - 2) .. "\n}\n" |
||||
stringData = "Config_Table = "..stringData; |
||||
print(stringData) |
||||
return stringData |
||||
end |
||||
|
||||
if Files["Config.lua"] == nil then |
||||
if Config_Table == nil then |
||||
Config_Table = {} |
||||
end |
||||
SaveData("Version","V0.1"); |
||||
end |
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
Config_Table = { |
||||
["Version"]="V0.1" |
||||
} |
Loading…
Reference in new issue