Latest post of the previous page:
Code: Select all
local function LongTableToString(arr, sSep)
local res={}
local convert=function(name,value)
local vtype=type(value)
if vtype=='number' or vtype=='string' or vtype=='boolean' or vtype=='table' then
if vtype=='string' then
value=string.format('%q',value)
elseif vtype=='table' then
value=LongTableToString(value,sSep)
else
value=tostring(value)
end
if name then value=name..'='..value end
table.insert(res,value)
end
end
for _,v in ipairs(arr) do convert(false,v) end
for i,v in pairs(arr) do if type(i)~='number' then convert(i,v) end end
return '{\n'..table.concat(res,sSep)..'\n}'
end