From Minetest Developer Wiki
Jump to navigation Jump to search
Mbox warning.png This page contains unofficial, low-quality Lua API documentation and is likely to be outdated or wrong. Do not rely on it!
For the official and up-to-date documentation, see Lua API Documentation.
Mbox warning.png This page has been proposed for deletion for the following reason: "Contains unofficial and potentially outdated, redundant and inconsistent Lua API information"
If you don't think that this page should be deleted, please explain why on the talk page.


<source> dump(obj) dump(obj, indent) </source>


Helper function which dumps a human-readable version of a value. If the value is simple and well-formed, this also produces syntax which could be used directly in Lua source code.


  • obj — The table or other value to print.
  • indent — The indent field specifies a indentation string, it defaults to a tab. Use the empty string to disable indentation.

For tables this performs a recursive deep traversal. Loops (such as the table containing a reference to itself) are detected, keeping the function from looping infinitely. Values that have already been seen are printed as <circular reference>.

For values that cannot be readily printed in Lua syntax, another placeholder such as <userdata> or <function> is printed.

Example 1

<source> local a = {1, 2, 3, message = "hello"} a.a = a print(dump(a)) </source>


<source> {[1] = 1, [2] = 2, [3] = 3, ["message"] = "Hello", ["a"] = <circular reference>} </source>

Example 2

<source> local b = minetest.get_connected_players(); b.f = function() end print(dump(b)) </source>


<source> {[1] = <userdata>, ["f"] = <function>} </source>