From 52cc1beb7d2e1a9ee0ff8f2f0791469d684ea89a Mon Sep 17 00:00:00 2001 From: Hersi Date: Tue, 14 Nov 2023 07:35:48 +0100 Subject: [PATCH] add dump() to utils --- scripts/common/util.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/common/util.lua b/scripts/common/util.lua index 7f10481..dcc1655 100644 --- a/scripts/common/util.lua +++ b/scripts/common/util.lua @@ -79,6 +79,19 @@ local function firstAlphaNum(s) return ''; end +local function dump(o) + if type(o) == 'table' then + local s = '{ ' + for k,v in pairs(o) do + if type(k) ~= 'number' then k = '"'..k..'"' end + s = s .. '['..k..'] = ' .. dump(v) .. ',' + end + return s .. '} ' + else + return tostring(o) + end +end + return { split = split, filter = filter, @@ -91,4 +104,5 @@ return { mix = mix, modIndex = modIndex, firstAlphaNum = firstAlphaNum, + dump = dump }