init.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. -- Add everything:
  2. local modname = "bird_nests"
  3. local modpath = minetest.get_modpath(modname)
  4. minetest.register_node(modname..":empty_nest", {
  5. description = "Empty bird nest",
  6. drawtype = "plantlike",
  7. visual_scale = 0.80,
  8. tiles = {modname.."_empty_nest.png"},
  9. inventory_image = modname.."_empty_nest.png",
  10. wield_image = modname.."_empty_nest.png",
  11. paramtype = "light",
  12. sunlight_propagates = true,
  13. walkable = false,
  14. buildable_to = true,
  15. groups = {snappy = 3, flammable = 2, attached_node = 1, bird_nest = 1},
  16. sounds = default.node_sound_leaves_defaults(),
  17. selection_box = {
  18. type = "fixed",
  19. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  20. },
  21. })
  22. minetest.register_node(modname..":full_nest", {
  23. description = "Bird nest with eggs",
  24. drawtype = "plantlike",
  25. visual_scale = 0.8,
  26. tiles = {modname.."_full_nest.png"},
  27. inventory_image = modname.."_full_nest.png",
  28. wield_image = modname.."_full_nest.png",
  29. paramtype = "light",
  30. sunlight_propagates = true,
  31. walkable = false,
  32. buildable_to = true,
  33. groups = {snappy = 3, flammable = 2, attached_node = 1, bird_nest = 1},
  34. sounds = default.node_sound_leaves_defaults(),
  35. selection_box = {
  36. type = "fixed",
  37. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  38. },
  39. drop = {
  40. items = {
  41. max_items = 1,
  42. {
  43. items = {modname..":small_egg 3", modname..":empty_nest"},
  44. rarity = 5,
  45. },
  46. {
  47. items = {modname..":small_egg 2", modname..":empty_nest"},
  48. },
  49. }
  50. },
  51. })
  52. minetest.register_craftitem(modname..":small_egg", {
  53. description = "Small Egg",
  54. inventory_image = modname.."_small_egg.png",
  55. stack_max = 99,
  56. })
  57. local growaction = function(pos, node)
  58. pos.y = pos.y + 1
  59. local over = minetest.get_node(pos)
  60. if over.name ~= "air" then
  61. return
  62. end
  63. local r = 15
  64. local pos0 = {x = pos.x - r, y = pos.y - r, z = pos.z - r}
  65. local pos1 = {x = pos.x + r, y = pos.y + r, z = pos.z + r}
  66. if #minetest.find_nodes_in_area(pos0, pos1, "group:bird_nest") > 0 then
  67. return
  68. end
  69. local r = math.random(1, 100)
  70. if r <= 15 then
  71. minetest.set_node(pos, {name=modname..":full_nest"})
  72. else
  73. minetest.set_node(pos, {name=modname..":empty_nest"})
  74. end
  75. end
  76. minetest.register_abm({
  77. nodenames = {"default:leaves", "default:pine_needles"},
  78. interval = 120,
  79. chance = 10,
  80. catch_up = true,
  81. action = growaction,
  82. })