sealife.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. local S = ethereal.intllib
  2. -- Seaweed
  3. minetest.register_node("ethereal:seaweed", {
  4. description = S("Seaweed"),
  5. drawtype = "plantlike",
  6. tiles = {"seaweed.png"},
  7. inventory_image = "seaweed.png",
  8. wield_image = "seaweed.png",
  9. paramtype = "light",
  10. walkable = false,
  11. climbable = true,
  12. drowning = 1,
  13. selection_box = {
  14. type = "fixed",
  15. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  16. },
  17. post_effect_color = {a = 64, r = 100, g = 100, b = 200},
  18. groups = {food_seaweed = 1, snappy = 3, flammable = 3},
  19. on_use = minetest.item_eat(1),
  20. sounds = default.node_sound_leaves_defaults(),
  21. after_dig_node = function(pos, node, metadata, digger)
  22. default.dig_up(pos, node, digger)
  23. end,
  24. })
  25. minetest.register_craft( {
  26. type = "shapeless",
  27. output = "dye:dark_green 3",
  28. recipe = {"ethereal:seaweed",},
  29. })
  30. -- agar powder
  31. minetest.register_craftitem("ethereal:agar_powder", {
  32. description = S("Agar Powder"),
  33. inventory_image = "ethereal_agar_powder.png",
  34. groups = {food_gelatin = 1, flammable = 2},
  35. })
  36. minetest.register_craft({
  37. output = "ethereal:agar_powder 3",
  38. recipe = {
  39. {"group:food_seaweed", "group:food_seaweed", "group:food_seaweed"},
  40. {"bucket:bucket_water", "bucket:bucket_water", "default:torch"},
  41. {"bucket:bucket_water", "bucket:bucket_water", "default:torch"},
  42. },
  43. replacements = {
  44. {"bucket:bucket_water", "bucket:bucket_empty 4"},
  45. },
  46. })
  47. -- Blue Coral
  48. minetest.register_node("ethereal:coral2", {
  49. description = S("Blue Coral"),
  50. drawtype = "plantlike",
  51. tiles = {"coral2.png"},
  52. inventory_image = "coral2.png",
  53. wield_image = "coral2.png",
  54. paramtype = "light",
  55. selection_box = {
  56. type = "fixed",
  57. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 1 / 4, 6 / 16},
  58. },
  59. light_source = 3,
  60. groups = {snappy = 3},
  61. sounds = default.node_sound_leaves_defaults(),
  62. })
  63. minetest.register_craft( {
  64. type = "shapeless",
  65. output = "dye:cyan 3",
  66. recipe = {"ethereal:coral2",},
  67. })
  68. -- Orange Coral
  69. minetest.register_node("ethereal:coral3", {
  70. description = S("Orange Coral"),
  71. drawtype = "plantlike",
  72. tiles = {"coral3.png"},
  73. inventory_image = "coral3.png",
  74. wield_image = "coral3.png",
  75. paramtype = "light",
  76. selection_box = {
  77. type = "fixed",
  78. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 1 / 4, 6 / 16},
  79. },
  80. light_source = 3,
  81. groups = {snappy = 3},
  82. sounds = default.node_sound_leaves_defaults(),
  83. })
  84. minetest.register_craft( {
  85. type = "shapeless",
  86. output = "dye:orange 3",
  87. recipe = {"ethereal:coral3",},
  88. })
  89. -- Pink Coral
  90. minetest.register_node("ethereal:coral4", {
  91. description = S("Pink Coral"),
  92. drawtype = "plantlike",
  93. tiles = {"coral4.png"},
  94. inventory_image = "coral4.png",
  95. wield_image = "coral4.png",
  96. paramtype = "light",
  97. selection_box = {
  98. type = "fixed",
  99. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 8 / 16, 6 / 16},
  100. },
  101. light_source = 3,
  102. groups = {snappy = 3},
  103. sounds = default.node_sound_leaves_defaults(),
  104. })
  105. minetest.register_craft( {
  106. type = "shapeless",
  107. output = "dye:pink 3",
  108. recipe = {"ethereal:coral4",},
  109. })
  110. -- Green Coral
  111. minetest.register_node("ethereal:coral5", {
  112. description = S("Green Coral"),
  113. drawtype = "plantlike",
  114. tiles = {"coral5.png"},
  115. inventory_image = "coral5.png",
  116. wield_image = "coral5.png",
  117. paramtype = "light",
  118. selection_box = {
  119. type = "fixed",
  120. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 3 / 16, 6 / 16},
  121. },
  122. light_source = 3,
  123. groups = {snappy = 3},
  124. sounds = default.node_sound_leaves_defaults(),
  125. })
  126. minetest.register_craft( {
  127. type = "shapeless",
  128. output = "dye:green 3",
  129. recipe = {"ethereal:coral5",},
  130. })
  131. -- Undersea Sand
  132. minetest.register_node("ethereal:sandy", {
  133. description = S("Sandy"),
  134. tiles = {"default_sand.png"},
  135. is_ground_content = true,
  136. groups = {
  137. crumbly = 3, falling_node = 1, sand = 1, not_in_creative_inventory = 1
  138. },
  139. drop = "default:sand",
  140. sounds = default.node_sound_sand_defaults(),
  141. })
  142. -- randomly generate coral or seaweed and have seaweed grow up to 14 high
  143. if ethereal.sealife == 1 then
  144. minetest.register_abm({
  145. label = "Grow coral/seaweed",
  146. nodenames = {"ethereal:sandy"},
  147. neighbors = {"group:water"},
  148. interval = 15,
  149. chance = 10,
  150. catch_up = false,
  151. action = function(pos, node)
  152. local sel = math.random(1, 5)
  153. pos.y = pos.y + 1
  154. local nod = minetest.get_node(pos).name
  155. if nod == "default:water_source"
  156. and sel > 1 then
  157. if minetest.get_node(pos).name == "default:water_source" then
  158. minetest.swap_node(pos, {name = "ethereal:coral" .. sel})
  159. end
  160. return
  161. end
  162. if nod == "ethereal:seaweed"
  163. or sel == 1 then
  164. local height = 0
  165. local high = 14
  166. while height < high
  167. and minetest.get_node(pos).name == "ethereal:seaweed" do
  168. height = height + 1
  169. pos.y = pos.y + 1
  170. end
  171. if pos.y < 1
  172. and height < high
  173. and minetest.get_node(pos).name == "default:water_source" then
  174. minetest.swap_node(pos, {name = "ethereal:seaweed"})
  175. end
  176. end
  177. end,
  178. })
  179. end