plants.lua 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. -- Lichen biome
  2. -- glowing fungi
  3. minetest.register_node("caverealms:fungus", {
  4. description = "Glowing Fungus",
  5. tiles = {"caverealms_fungi.png"},
  6. inventory_image = "caverealms_fungi.png",
  7. wield_image = "caverealms_fungi.png",
  8. is_ground_content = true,
  9. groups = {oddly_breakable_by_hand = 3, attached_node = 1},
  10. light_source = 5,
  11. paramtype = "light",
  12. drawtype = "plantlike",
  13. walkable = false,
  14. buildable_to = true,
  15. visual_scale = 1.0,
  16. selection_box = {
  17. type = "fixed",
  18. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  19. },
  20. })
  21. -- mycena mushroom
  22. minetest.register_node("caverealms:mycena", {
  23. description = "Mycena Mushroom",
  24. tiles = {"caverealms_mycena.png"},
  25. inventory_image = "caverealms_mycena.png",
  26. wield_image = "caverealms_mycena.png",
  27. is_ground_content = true,
  28. groups = {oddly_breakable_by_hand = 3, attached_node = 1},
  29. light_source = 6,
  30. paramtype = "light",
  31. drawtype = "plantlike",
  32. walkable = false,
  33. buildable_to = true,
  34. visual_scale = 1.0,
  35. selection_box = {
  36. type = "fixed",
  37. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
  38. },
  39. })
  40. -- giant mushroom
  41. if minetest.get_modpath("ethereal") then
  42. minetest.register_alias("caverealms:mushroom_cap", "ethereal:mushroom")
  43. minetest.register_alias("caverealms:mushroom_stem", "ethereal:mushroom_trunk")
  44. else
  45. -- stem
  46. minetest.register_node("caverealms:mushroom_stem", {
  47. description = "Giant Mushroom Stem",
  48. tiles = {"caverealms_mushroom_stem.png"},
  49. is_ground_content = true,
  50. groups = {choppy=2, oddly_breakable_by_hand=1},
  51. })
  52. -- cap
  53. minetest.register_node("caverealms:mushroom_cap", {
  54. description = "Giant Mushroom Cap",
  55. tiles = {"caverealms_mushroom_cap.png"},
  56. is_ground_content = true,
  57. groups = {choppy=2, oddly_breakable_by_hand=1,},
  58. drop = {
  59. max_items = 1,
  60. items = {
  61. {items = {"caverealms:mushroom_sapling"}, rarity = 20},
  62. {items = {"caverealms:mushroom_cap"}}
  63. }
  64. },
  65. })
  66. -- sapling
  67. minetest.register_node("caverealms:mushroom_sapling", {
  68. description = "Mushroom Tree Sapling",
  69. drawtype = "plantlike",
  70. tiles = {"caverealms_mushroom_sapling.png"},
  71. paramtype = "light",
  72. sunlight_propagates = true,
  73. is_ground_content = false,
  74. walkable = false,
  75. selection_box = {
  76. type = "fixed",
  77. fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
  78. },
  79. groups = {snappy = 2, dig_immediate = 3, flammable = 2},
  80. sounds = default.node_sound_leaves_defaults(),
  81. })
  82. end
  83. -- gills
  84. minetest.register_node("caverealms:mushroom_gills", {
  85. description = "Giant Mushroom Gills",
  86. tiles = {"caverealms_mushroom_gills.png"},
  87. is_ground_content = true,
  88. light_source = 10,
  89. groups = {choppy=2, oddly_breakable_by_hand=1},
  90. drawtype = "plantlike",
  91. paramtype = "light",
  92. })
  93. -- Saplings
  94. -- grow trees
  95. local add_tree = function (pos, ofx, ofy, ofz, schem)
  96. if not schem then
  97. print ("Schematic not found")
  98. return
  99. end
  100. minetest.swap_node(pos, {name = "air"})
  101. minetest.place_schematic(
  102. {x = pos.x - ofx, y = pos.y - ofy, z = pos.z - ofz},
  103. schem, 0, nil, false)
  104. end
  105. local path = minetest.get_modpath("caverealms").."/schematics/"
  106. -- giant mushrooms
  107. function grow_caverealms_mushroom(pos)
  108. add_tree(pos, 5, 0, 5, path .. "shroom.mts")
  109. end
  110. -- height check
  111. local function enough_height(pos, height)
  112. local nod = minetest.line_of_sight(
  113. {x = pos.x, y = pos.y + 1, z = pos.z},
  114. {x = pos.x, y = pos.y + height, z = pos.z})
  115. if not nod then
  116. return false
  117. else
  118. return true
  119. end
  120. end
  121. minetest.register_abm({
  122. label = "Caverealms grow sapling",
  123. nodenames = {"ethereal:mushroom_sapling", "caverealms:mushroom_sapling"},
  124. interval = 10,
  125. chance = 50,
  126. catch_up = false,
  127. action = function(pos, node)
  128. local light_level = minetest.get_node_light(pos)
  129. -- check light level
  130. if not light_level or light_level > 10 then
  131. return
  132. end
  133. -- get node under sapling
  134. local under = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z}).name
  135. -- check if registered
  136. if not minetest.registered_nodes[node.name] then
  137. return
  138. end
  139. -- ethereal sapling on lichen stone
  140. if node.name == "ethereal:mushroom_sapling"
  141. and under == "caverealms:stone_with_lichen"
  142. and enough_height(pos, 10) then
  143. grow_caverealms_mushroom(pos)
  144. -- caverealms sapling on lichen stone
  145. elseif node.name == "caverealms:mushroom_sapling"
  146. and under == "caverealms:stone_with_lichen"
  147. and enough_height(pos, 10) then
  148. grow_caverealms_mushroom(pos)
  149. end
  150. end,
  151. })
  152. -- spread moss/lichen/algae to nearby cobblestone
  153. minetest.register_abm({
  154. label = "Caverealms stone spread",
  155. nodenames = {
  156. "caverealms:stone_with_moss",
  157. "caverealms:stone_with_lichen",
  158. "caverealms:stone_with_algae",
  159. },
  160. neighbors = {"air"},
  161. interval = 16,
  162. chance = 50,
  163. catch_up = false,
  164. action = function(pos, node)
  165. local num = minetest.find_nodes_in_area_under_air(
  166. {x = pos.x - 1, y = pos.y - 2, z = pos.z - 1},
  167. {x = pos.x + 1, y = pos.y + 1, z = pos.z + 1},
  168. "default:cobble")
  169. if #num > 0 then
  170. minetest.set_node(num[math.random(#num)], {name = node.name})
  171. end
  172. end,
  173. })