1 -- Returns the greatest numeric key in a table.
2 function xdecor.maxn(T)
5 if k > n then n = k end
10 -- Returns the length of an hash table.
11 function xdecor.tablelen(T)
13 for _ in pairs(T) do n = n + 1 end
17 -- Deep copy of a table. Borrowed from mesecons mod (https://github.com/Jeija/minetest-mod-mesecons).
18 function xdecor.tablecopy(T)
19 if type(T) ~= "table" then return T end -- No need to copy.
22 for k, v in pairs(T) do
23 if type(v) == "table" then
24 new[k] = xdecor.tablecopy(v)
32 -- Return true if a def is accepting for stair
33 function xdecor.stairs_valid_def(def)
34 return (def.drawtype == "normal" or def.drawtype:sub(1,5) == "glass") and
35 (def.groups.cracky or def.groups.choppy) and
36 not def.on_construct and
37 not def.after_place_node and
38 not def.on_rightclick and
40 not def.allow_metadata_inventory_take and
41 not (def.groups.not_in_creative_inventory == 1) and
42 not (def.groups.not_cuttable == 1) and
43 not def.groups.wool and
44 (def.tiles and type(def.tiles[1]) == "string" and not
45 def.tiles[1]:find("default_mineral")) and
48 def.description ~= "" and