nodes_chests.lua 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. -- TODO: make these chests as chests and indicate that they are owned by npc
  2. -- TODO: add bags (not for carrying around but for decoration)
  3. -- Boilerplate to support localized strings if intllib mod is installed.
  4. local S = cottages.S
  5. cottages_chests = {}
  6. -- uses default.chest_formspec for now
  7. cottages_chests.on_construct = function(pos)
  8. local meta = minetest.get_meta(pos)
  9. meta:set_string("formspec",default.chest_formspec)
  10. -- meta:set_string("infotext", "Chest")
  11. local inv = meta:get_inventory()
  12. inv:set_size("main", 8*4)
  13. end
  14. cottages_chests.can_dig = function(pos,player)
  15. local meta = minetest.get_meta(pos);
  16. local inv = meta:get_inventory()
  17. return inv:is_empty("main")
  18. end
  19. -- the chests do not need receipes since they are only placeholders and not intended to be built by players
  20. -- (they are later on supposed to be filled with diffrent items by fill_chest.lua)
  21. minetest.register_node("cottages:chest_private", {
  22. description = S("private NPC chest"),
  23. infotext = "chest containing the possesions of one of the inhabitants",
  24. tiles = cottages.texture_chest,
  25. paramtype2 = "facedir",
  26. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  27. legacy_facedir_simple = true,
  28. on_construct = cottages_chests.on_construct,
  29. can_dig = cottages_chests.can_dig,
  30. is_ground_content = false,
  31. })
  32. minetest.register_node("cottages:chest_work", {
  33. description = S("chest for work utils and kitchens"),
  34. infotext = "everything the inhabitant needs for his work",
  35. tiles = cottages.texture_chest,
  36. paramtype2 = "facedir",
  37. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  38. legacy_facedir_simple = true,
  39. on_construct = cottages_chests.on_construct,
  40. can_dig = cottages_chests.can_dig,
  41. is_ground_content = false,
  42. })
  43. minetest.register_node("cottages:chest_storage", {
  44. description = S("storage chest"),
  45. infotext = "stored food reserves",
  46. tiles = cottages.texture_chest,
  47. paramtype2 = "facedir",
  48. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
  49. legacy_facedir_simple = true,
  50. on_construct = cottages_chests.on_construct,
  51. can_dig = cottages_chests.can_dig,
  52. is_ground_content = false,
  53. })