summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryou <ovvv@web.de>2018-02-08 19:17:06 +0100
committerSmallJoker <mk939@ymail.com>2018-06-03 17:32:00 +0200
commit77250300676bc08cff4e687df0b6ac86ea35a6e4 (patch)
treefccc25c5f0733bde196c5753a1c8bbc0d9eb872a
parentbb28afcfc337b73bff2b46ff1a1b8844e035c96e (diff)
downloadminetest-77250300676bc08cff4e687df0b6ac86ea35a6e4.tar.gz
minetest-77250300676bc08cff4e687df0b6ac86ea35a6e4.tar.bz2
minetest-77250300676bc08cff4e687df0b6ac86ea35a6e4.zip
Allow dumping userdata (#7012)
-rw-r--r--builtin/common/misc_helpers.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 0686c18da..ab2da14ea 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -120,7 +120,12 @@ end
-- The dumped and level arguments are internal-only.
function dump(o, indent, nested, level)
- if type(o) ~= "table" then
+ local t = type(o)
+ if not level and t == "userdata" then
+ -- when userdata (e.g. player) is passed directly, print its metatable:
+ return "userdata metatable: " .. dump(getmetatable(o))
+ end
+ if t ~= "table" then
return basic_dump(o)
end
-- Contains table -> true/nil of currently nested tables