I handle it by writing and reading the file like this. I can then zip it into the file.
function Formatted(_Table)
local Ram, Stack, Out = {},{},{}
local Space = 1
local FormattedOutput = "DosyaDataTablosu=\n{\n"
while true do
local Size = 0
for i,j in pairs(_Table) do
Size = Size + 1
end
local CurrentIndex = 1
for i,j in pairs(_Table) do
if (Ram[_Table] == nil) or (CurrentIndex >= Ram[_Table]) then
if (string.find(FormattedOutput,"}",FormattedOutput:len())) then
FormattedOutput = FormattedOutput .. ",\n"
elseif not (string.find(FormattedOutput,"\n",FormattedOutput:len())) then
FormattedOutput = FormattedOutput .. "\n"
end
table.insert(Out,FormattedOutput)
FormattedOutput = ""
local key
if (type(i) == "number" or type(i) == "boolean") then
key = "["..tostring(i).."]"
else
key = "[\""..tostring(i).."\"]"
end
if (type(j) == "number" or type(j) == "boolean") then
FormattedOutput = FormattedOutput .. string.rep('\t',Space) .. key .. " = "..tostring(j)
elseif (type(j) == "table") then
FormattedOutput = FormattedOutput .. string.rep('\t',Space) .. key .. " =\n"
FormattedOutput = FormattedOutput .. string.rep('\t',Space) .. "{\n"
table.insert(Stack,_Table)
table.insert(Stack,j)
Ram[_Table] = CurrentIndex+1
break
else
FormattedOutput = FormattedOutput .. string.rep('\t',Space) .. key .. " = \""..tostring(j).."\""
end
if (CurrentIndex == Size) then
FormattedOutput = FormattedOutput .. "\n" .. string.rep('\t',Space-1) .. "}"
else
FormattedOutput = FormattedOutput .. ","
end
else
-- close the table
if (CurrentIndex == Size) then
FormattedOutput = FormattedOutput .. "\n" .. string.rep('\t',Space-1) .. "}"
end
end
CurrentIndex = CurrentIndex + 1
end
if (Size == 0) then
FormattedOutput = FormattedOutput .. "\n" .. string.rep('\t',Space-1) .. "}"
end
if (#Stack > 0) then
_Table = Stack[#Stack]
Stack[#Stack] = nil
Space = Ram[_Table] == nil and Space + 1 or Space - 1
else
break
end
end
table.insert(Out,FormattedOutput)
FormattedOutput = table.concat(Out)
return FormattedOutput
end
function FileSave()
local file= io.open(FileData, "w")
file:write(Formatted(DosyaDataTablosu))
file:close()
end
function FileRead()
local file= io.open(FileData, "r")
if (file~=nil) then
dofile(FileData)
file:close()
end
end