init.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. mailbox = mailbox or {}
  2. mailbox.modpath = minetest.get_modpath("mailbox")
  3. -- Stores mailbox information.
  4. mailbox.boxes = mailbox.boxes or {}
  5. -- Items to reject (also rejects starter items).
  6. mailbox.reject_items = {
  7. "default:ice",
  8. "bones:bones_type2",
  9. "default:cobble",
  10. "default:snow",
  11. }
  12. dofile(mailbox.modpath .. "/functions.lua")
  13. dofile(mailbox.modpath .. "/storage.lua")
  14. if not mailbox.run_once then
  15. mailbox.load()
  16. minetest.register_on_player_receive_fields(function(...)
  17. return mailbox.on_receive_fields(...)
  18. end)
  19. minetest.register_craft({
  20. output ="mailbox:mailbox",
  21. recipe = {
  22. {"", "default:steel_ingot", "" },
  23. {"default:steel_ingot", "", "default:steel_ingot"},
  24. {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
  25. },
  26. })
  27. local mb_cbox = {
  28. type = "fixed",
  29. fixed = { -5/16, -8/16, -8/16, 5/16, 2/16, 8/16 },
  30. }
  31. minetest.register_node("mailbox:mailbox", {
  32. paramtype = "light",
  33. drawtype = "mesh",
  34. mesh = "mailbox_mailbox.obj",
  35. description = "Mailbox\n\nUpgrade with a CLU to get email when items are deposited.",
  36. tiles = {
  37. "mailbox_red_metal.png",
  38. "mailbox_white_metal.png",
  39. "mailbox_grey_metal.png",
  40. },
  41. selection_box = mb_cbox,
  42. collision_box = mb_cbox,
  43. paramtype2 = "facedir",
  44. groups = utility.dig_groups("furniture", {
  45. immovable = 1,
  46. }),
  47. sounds = default.node_sound_wood_defaults(),
  48. on_rotate = screwdriver.rotate_simple,
  49. on_punch = function(...)
  50. return mailbox.on_punch(...)
  51. end,
  52. after_place_node = function(...)
  53. return mailbox.after_place_node(...)
  54. end,
  55. on_destruct = function(...)
  56. return mailbox.on_destruct(...)
  57. end,
  58. on_rightclick = function(...)
  59. return mailbox.on_rightclick(...)
  60. end,
  61. can_dig = function(...)
  62. return mailbox.can_dig(...)
  63. end,
  64. on_metadata_inventory_put = function(...)
  65. return mailbox.on_metadata_inventory_put(...)
  66. end,
  67. allow_metadata_inventory_put = function(...)
  68. return mailbox.allow_metadata_inventory_put(...)
  69. end,
  70. allow_metadata_inventory_move = function(...)
  71. return mailbox.allow_metadata_inventory_move(...)
  72. end,
  73. allow_metadata_inventory_take = function(...)
  74. return mailbox.allow_metadata_inventory_take(...)
  75. end,
  76. on_blast = function(...)
  77. return mailbox.on_blast(...)
  78. end,
  79. -- Called by rename LBM.
  80. _on_rename_check = function(pos)
  81. local meta = minetest.get_meta(pos)
  82. local owner = meta:get_string("owner")
  83. -- Nobody placed this block.
  84. if owner == "" then
  85. return
  86. end
  87. local dname = rename.gpn(owner)
  88. meta:set_string("rename", dname)
  89. meta:set_string("infotext", "Mailbox (Owned by <" .. dname .. ">!)")
  90. end,
  91. })
  92. local c = "mailbox:core"
  93. local f = mailbox.modpath .. "/init.lua"
  94. reload.register_file(c, f, false)
  95. minetest.register_on_shutdown(function()
  96. mailbox.save()
  97. end)
  98. mailbox.run_once = true
  99. end