summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/clua/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/dat/clua/util.lua')
-rw-r--r--crawl-ref/source/dat/clua/util.lua26
1 files changed, 25 insertions, 1 deletions
diff --git a/crawl-ref/source/dat/clua/util.lua b/crawl-ref/source/dat/clua/util.lua
index fab5720a7a..2aa4f2fe85 100644
--- a/crawl-ref/source/dat/clua/util.lua
+++ b/crawl-ref/source/dat/clua/util.lua
@@ -250,4 +250,28 @@ function util.Timer:mark(what)
local now = crawl.millis()
crawl.mpr(what .. ": " .. (now - last) .. " ms")
self.last = now
-end \ No newline at end of file
+end
+
+-- Turn contents of a table into a human readable string
+function table_to_string(table, depth)
+ depth = depth or 0
+
+ local indent = string.rep(" ", depth * 4)
+
+ local str = ""
+
+ for key, value in pairs(table) do
+ str = str .. indent .. key .. ": "
+
+ if type(value) == "table" then
+ str = str .. "\n" .. table_to_string(value, depth + 1)
+ elseif type(value) == "function" then
+ str = str .. "function"
+ else
+ str = str .. value
+ end
+ str = str .. "\n"
+ end
+
+ return str
+end