2021-06-03 00:57:46 +00:00
|
|
|
--- Returns the key value pairs in a table as a single string
|
|
|
|
-- @param tbl table input table
|
|
|
|
-- @param sep string key value seperator
|
|
|
|
-- @param new_line string key value pair delimiter
|
|
|
|
-- @return string concatenated table pairs
|
2021-06-27 23:56:29 +00:00
|
|
|
local function table_tostring(tbl, sep, new_line)
|
2021-07-01 05:11:34 +00:00
|
|
|
if type(sep) ~= "string" then sep = ": " end
|
|
|
|
if type(new_line) ~= "string" then new_line = ", " end
|
|
|
|
local ret = {}
|
|
|
|
if type(tbl) ~= "table" then return "Error: input not table!" end
|
|
|
|
for key,value in pairs(tbl) do
|
|
|
|
table.insert(ret,tostring(key) .. sep .. tostring(value) .. new_line)
|
|
|
|
end
|
|
|
|
return table.concat(ret,"")
|
2021-06-03 00:57:46 +00:00
|
|
|
end
|
2021-06-27 23:56:29 +00:00
|
|
|
|
|
|
|
return table_tostring
|