From: you Date: Thu, 8 Feb 2018 18:17:06 +0000 (+0100) Subject: Allow dumping userdata (#7012) X-Git-Tag: 5.0.0~590 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a6bb2c4ea8cfcfeeb6f78129663a3c3237891ce2;p=oweals%2Fminetest.git Allow dumping userdata (#7012) --- 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