1 function basic_dump2(o)
2 if type(o) == "number" then
4 elseif type(o) == "string" then
5 return string.format("%q", o)
6 elseif type(o) == "boolean" then
8 elseif type(o) == "function" then
10 elseif type(o) == "userdata" then
12 elseif type(o) == "nil" then
15 error("cannot dump a " .. type(o))
20 function dump2(o, name, dumped)
24 if type(o) == "number" or type(o) == "string" or type(o) == "boolean"
25 or type(o) == "function" or type(o) == "nil"
26 or type(o) == "userdata" then
27 io.write(basic_dump2(o), "\n")
28 elseif type(o) == "table" then
30 io.write(dumped[o], "\n")
33 io.write("{}\n") -- new table
34 for k,v in pairs(o) do
35 local fieldname = string.format("%s[%s]", name, basic_dump2(k))
36 dump2(v, fieldname, dumped)
40 error("cannot dump a " .. type(o))
45 function dump(o, dumped)
47 if type(o) == "number" then
49 elseif type(o) == "string" then
50 return string.format("%q", o)
51 elseif type(o) == "table" then
53 return "<circular reference>"
57 for k,v in pairs(o) do
58 t[#t+1] = "" .. k .. " = " .. dump(v, dumped)
60 return "{" .. table.concat(t, ", ") .. "}"
61 elseif type(o) == "boolean" then
63 elseif type(o) == "function" then
65 elseif type(o) == "userdata" then
67 elseif type(o) == "nil" then
70 error("cannot dump a " .. type(o))
76 -- Built-in node types. Also defined in C.
79 minetest.register_node("air", {
82 light_propagates = true,
83 sunlight_propagates = true,
88 air_equivalent = true,
91 minetest.register_node("ignore", {
94 light_propagates = false,
95 sunlight_propagates = false,
99 buildable_to = true, -- A way to remove accidentally placed ignores
100 air_equivalent = true,