projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
501f936
)
Allow dumping userdata (#7012)
author
you
<ovvv@web.de>
Thu, 8 Feb 2018 18:17:06 +0000
(19:17 +0100)
committer
SmallJoker
<SmallJoker@users.noreply.github.com>
Thu, 8 Feb 2018 18:17:06 +0000
(19:17 +0100)
builtin/common/misc_helpers.lua
patch
|
blob
|
history
diff --git
a/builtin/common/misc_helpers.lua
b/builtin/common/misc_helpers.lua
index baa9be2681f1718cf50b1f9683846938c3273da2..88bae2b0b642ccb422573cf412cc4c69820b3dbb 100644
(file)
--- 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