init.lua 847 B

123456789101112131415161718192021222324252627
  1. minetest.register_node("chest:chest", {
  2. description = "Chest",
  3. tiles ={"chest_chest.png^[sheet:2x2:0,0", "chest_chest.png^[sheet:2x2:0,0",
  4. "chest_chest.png^[sheet:2x2:1,0", "chest_chest.png^[sheet:2x2:1,0",
  5. "chest_chest.png^[sheet:2x2:1,0", "chest_chest.png^[sheet:2x2:0,1"},
  6. paramtype2 = "facedir",
  7. groups = {dig_immediate=2,choppy=3},
  8. is_ground_content = false,
  9. on_construct = function(pos)
  10. local meta = minetest.get_meta(pos)
  11. meta:set_string("formspec",
  12. "size[8,9]"..
  13. "list[current_name;main;0,0;8,4;]"..
  14. "list[current_player;main;0,5;8,4;]" ..
  15. "listring[]")
  16. meta:set_string("infotext", "Chest")
  17. local inv = meta:get_inventory()
  18. inv:set_size("main", 8*4)
  19. end,
  20. can_dig = function(pos,player)
  21. local meta = minetest.get_meta(pos);
  22. local inv = meta:get_inventory()
  23. return inv:is_empty("main")
  24. end,
  25. })