3 local default_can_dig = function(pos,player)
4 local meta = minetest.get_meta(pos)
5 return meta:get_inventory():is_empty("main")
8 fancy_gui = default.gui_bg..default.gui_bg_img..default.gui_slots
9 local default_inventory_size = 32
10 local default_inventory_formspecs = {
11 ["8"]="size[8,6]"..fancy_gui..
12 "list[context;main;0,0;8,1;]"..
13 "list[current_player;main;0,2;8,4;]",
15 ["16"]="size[8,7]"..fancy_gui..
16 "list[context;main;0,0;8,2;]"..
17 "list[current_player;main;0,3;8,4;]",
19 ["24"]="size[8,8]"..fancy_gui..
20 "list[context;main;0,0;8,3;]"..
21 "list[current_player;main;0,4;8,4;]",
23 ["32"]="size[8,9]"..fancy_gui..
24 "list[context;main;0,0.3;8,4;]"..
25 "list[current_player;main;0,4.85;8,1;]"..
26 "list[current_player;main;0,6.08;8,3;8]"..
27 default.get_hotbar_bg(0,4.85),
30 local function get_formspec_by_size(size)
31 local formspec = default_inventory_formspecs[tostring(size)]
32 return formspec or default_inventory_formspecs
35 function xdecor.register(name, def)
36 def.drawtype = def.drawtype or (def.node_box and "nodebox")
37 def.paramtype = def.paramtype or "light"
39 if not (def.drawtype == "glasslike_framed"
40 or def.drawtype == "glasslike_framed_optional"
41 or def.drawtype == "plantlike"
42 or def.drawtype == "signlike"
43 or def.drawtype == "normal") then
44 def.paramtype2 = def.paramtype2 or "facedir"
47 local infotext = def.infotext
48 local inventory = def.inventory
52 def.on_construct = def.on_construct or function(pos)
53 local meta = minetest.get_meta(pos)
55 meta:set_string("infotext", infotext)
57 local size = inventory.size or default_inventory_size
58 meta:get_inventory():set_size("main", size)
59 meta:set_string("formspec", inventory.formspec or get_formspec_by_size(size))
62 def.can_dig = def.can_dig or default_can_dig
63 elseif infotext and not def.on_construct then
64 def.on_construct = function(pos)
65 local meta = minetest.get_meta(pos)
66 meta:set_string("infotext", infotext)
70 minetest.register_node("xdecor:" .. name, def)