aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authoryou <ovvv@web.de>2018-02-08 19:17:06 +0100
committerSmallJoker <SmallJoker@users.noreply.github.com>2018-02-08 19:17:06 +0100
commita6bb2c4ea8cfcfeeb6f78129663a3c3237891ce2 (patch)
treee6ef11eb30a835262a4811ae8b225975b854d2fc /builtin
parent501f936b37046ab469844c5349054369de3e7fc6 (diff)
downloadminetest-a6bb2c4ea8cfcfeeb6f78129663a3c3237891ce2.tar.gz
minetest-a6bb2c4ea8cfcfeeb6f78129663a3c3237891ce2.tar.bz2
minetest-a6bb2c4ea8cfcfeeb6f78129663a3c3237891ce2.zip
Allow dumping userdata (#7012)
Diffstat (limited to 'builtin')
-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 baa9be268..88bae2b0b 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