You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
1 year ago
|
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)
|
||
1 year ago
|
file.open("Config.lua", "w+");
|
||
1 year ago
|
Config_Table[key] = value;
|
||
|
local tableStr = TableToStr(Config_Table);
|
||
|
file.write(tableStr);
|
||
1 year ago
|
file.close();
|
||
|
--print(key.."-"..value.."has been Saved");
|
||
1 year ago
|
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;
|
||
1 year ago
|
--print(stringData)
|
||
1 year ago
|
return stringData
|
||
|
end
|
||
|
|
||
|
if Files["Config.lua"] == nil then
|
||
|
if Config_Table == nil then
|
||
|
Config_Table = {}
|
||
|
end
|
||
|
SaveData("Version","V0.1");
|
||
|
end
|