mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-16 04:53:00 +00:00
Starbeamrainbowlabs
1f44e240fb
..it was getting rather long, because Lua doesn't exactly come with batteries included :-/
18 lines
665 B
Lua
18 lines
665 B
Lua
--- 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
|
|
function worldeditadditions.table_tostring(tbl, sep, new_line)
|
|
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
|
|
ret:append(key)
|
|
ret:append(sep)
|
|
ret:append(value)
|
|
ret:append(new_line)
|
|
end
|
|
return ret:concat("")
|
|
end
|