From f709d12b75de63ff6856f06cb8c799a8ddb11fd6 Mon Sep 17 00:00:00 2001 From: VorTechnix <45538536+VorTechnix@users.noreply.github.com> Date: Wed, 30 Jun 2021 22:11:34 -0700 Subject: [PATCH] Update table_tostring.lua --- .../utils/tables/table_tostring.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/worldeditadditions/utils/tables/table_tostring.lua b/worldeditadditions/utils/tables/table_tostring.lua index 89f9b80..4a13586 100644 --- a/worldeditadditions/utils/tables/table_tostring.lua +++ b/worldeditadditions/utils/tables/table_tostring.lua @@ -4,17 +4,14 @@ -- @param new_line string key value pair delimiter -- @return string concatenated table pairs local function 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 - table.insert(ret,key) - table.insert(ret,sep) - table.insert(ret,value) - table.insert(ret,new_line) - end - return table.concat(ret,"") + 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,"") end return table_tostring