From 99c7cdc387930f4fbb5ecfbd1675fe88f1bbb691 Mon Sep 17 00:00:00 2001 From: Guillaume DOTT Date: Sat, 10 Nov 2012 15:36:16 +0100 Subject: [PATCH] Added a function to dump tables for easier debug --- util.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/util.lua b/util.lua index a850a17..a2fe705 100644 --- a/util.lua +++ b/util.lua @@ -1 +1,14 @@ function join_tables(t1, t2) for k,v in ipairs(t2) do table.insert(t1, v) end return t1 end + +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