sealife.lua 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. local S = ethereal.intllib
  2. -- Seaweed
  3. minetest.register_node("ethereal:seaweed", {
  4. description = S("Seaweed"),
  5. drawtype = "plantlike",
  6. tiles = {"ethereal_seaweed.png"},
  7. inventory_image = "ethereal_seaweed.png",
  8. wield_image = "ethereal_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 Glow Coral"),
  50. drawtype = "plantlike",
  51. tiles = {"ethereal_coral_blue.png"},
  52. inventory_image = "ethereal_coral_blue.png",
  53. wield_image = "ethereal_coral_blue.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. output = "dye:cyan 3",
  65. recipe = {{"ethereal:coral2"}}
  66. })
  67. -- Orange Coral
  68. minetest.register_node("ethereal:coral3", {
  69. description = S("Orange Glow Coral"),
  70. drawtype = "plantlike",
  71. tiles = {"ethereal_coral_orange.png"},
  72. inventory_image = "ethereal_coral_orange.png",
  73. wield_image = "ethereal_coral_orange.png",
  74. paramtype = "light",
  75. selection_box = {
  76. type = "fixed",
  77. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 1 / 4, 6 / 16}
  78. },
  79. light_source = 3,
  80. groups = {snappy = 3},
  81. sounds = default.node_sound_leaves_defaults()
  82. })
  83. minetest.register_craft( {
  84. output = "dye:orange 3",
  85. recipe = {{"ethereal:coral3"}}
  86. })
  87. -- Pink Coral
  88. minetest.register_node("ethereal:coral4", {
  89. description = S("Pink Glow Coral"),
  90. drawtype = "plantlike",
  91. tiles = {"ethereal_coral_pink.png"},
  92. inventory_image = "ethereal_coral_pink.png",
  93. wield_image = "ethereal_coral_pink.png",
  94. paramtype = "light",
  95. selection_box = {
  96. type = "fixed",
  97. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 8 / 16, 6 / 16}
  98. },
  99. light_source = 3,
  100. groups = {snappy = 3},
  101. sounds = default.node_sound_leaves_defaults()
  102. })
  103. minetest.register_craft( {
  104. output = "dye:pink 3",
  105. recipe = {{"ethereal:coral4"}}
  106. })
  107. -- Green Coral
  108. minetest.register_node("ethereal:coral5", {
  109. description = S("Green Glow Coral"),
  110. drawtype = "plantlike",
  111. tiles = {"ethereal_coral_green.png"},
  112. inventory_image = "ethereal_coral_green.png",
  113. wield_image = "ethereal_coral_green.png",
  114. paramtype = "light",
  115. selection_box = {
  116. type = "fixed",
  117. fixed = {-6 / 16, -0.5, -6 / 16, 6 / 16, 3 / 16, 6 / 16}
  118. },
  119. light_source = 3,
  120. groups = {snappy = 3},
  121. sounds = default.node_sound_leaves_defaults()
  122. })
  123. minetest.register_craft( {
  124. output = "dye:green 3",
  125. recipe = {{"ethereal:coral5"}}
  126. })
  127. -- Undersea Sand
  128. minetest.register_node("ethereal:sandy", {
  129. description = S("Sandy"),
  130. tiles = {"default_sand.png"},
  131. is_ground_content = true,
  132. groups = {
  133. crumbly = 3, falling_node = 1, sand = 1, not_in_creative_inventory = 1
  134. },
  135. drop = "default:sand",
  136. sounds = default.node_sound_sand_defaults()
  137. })
  138. -- randomly generate coral or seaweed and have seaweed grow up to 14 high
  139. if ethereal.sealife == 1 then
  140. minetest.register_abm({
  141. label = "Grow coral/seaweed",
  142. nodenames = {"ethereal:sandy"},
  143. neighbors = {"group:water"},
  144. interval = 15,
  145. chance = 10,
  146. catch_up = false,
  147. action = function(pos, node)
  148. local sel = math.random(6)
  149. pos.y = pos.y + 1
  150. local nod = minetest.get_node(pos).name
  151. if nod == "default:water_source"
  152. and sel == 6 then
  153. minetest.swap_node(pos, {name = "ethereal:sponge_wet"})
  154. return
  155. end
  156. if nod == "default:water_source"
  157. and sel > 1 then
  158. minetest.swap_node(pos, {name = "ethereal:coral" .. sel})
  159. return
  160. end
  161. if nod == "ethereal:seaweed"
  162. or sel == 1 then
  163. local height = 0
  164. local high = 14
  165. while height < high
  166. and minetest.get_node(pos).name == "ethereal:seaweed" do
  167. height = height + 1
  168. pos.y = pos.y + 1
  169. end
  170. if pos.y < 1
  171. and height < high
  172. and minetest.get_node(pos).name == "default:water_source" then
  173. minetest.swap_node(pos, {name = "ethereal:seaweed"})
  174. end
  175. end
  176. end
  177. })
  178. end
  179. -- sponges
  180. minetest.register_node("ethereal:sponge_air", {
  181. drawtype = "airlike",
  182. paramtype = "light",
  183. walkable = false,
  184. buildable_to = true,
  185. sunlight_propagates = true,
  186. pointable = false,
  187. drop = "",
  188. groups = {not_in_creative_inventory = 1}
  189. })
  190. minetest.register_node("ethereal:sponge", {
  191. description = S("Sponge"),
  192. tiles = {"ethereal_sponge.png"},
  193. groups = {crumbly = 3},
  194. sounds = default.node_sound_sand_defaults(),
  195. after_place_node = function(pos, placer, itemstack, pointed_thing)
  196. -- get player name
  197. local name = placer:get_player_name()
  198. -- is area protected
  199. if minetest.is_protected(pos, name) then
  200. return
  201. end
  202. -- get water nodes within range
  203. local num = minetest.find_nodes_in_area(
  204. {x = pos.x - 3, y = pos.y - 3, z = pos.z - 3},
  205. {x = pos.x + 3, y = pos.y + 3, z = pos.z + 3},
  206. {"group:water"})
  207. -- no water
  208. if #num == 0 then return end
  209. -- replace water nodes with sponge air
  210. for _, w in pairs(num) do
  211. if not minetest.is_protected(pos, name) then
  212. minetest.swap_node(w, {name = "ethereal:sponge_air"})
  213. end
  214. end
  215. -- replace dry sponge with wet sponge
  216. minetest.swap_node(pos, {name = "ethereal:sponge_wet"})
  217. end
  218. })
  219. minetest.register_node("ethereal:sponge_wet", {
  220. description = S("Wet sponge"),
  221. tiles = {"ethereal_sponge_wet.png"},
  222. groups = {crumbly = 3},
  223. sounds = default.node_sound_sand_defaults()
  224. })
  225. -- cook wet sponge into dry sponge
  226. minetest.register_craft({
  227. type = "cooking",
  228. recipe = "ethereal:sponge_wet",
  229. output = "ethereal:sponge",
  230. cooktime = 3
  231. })
  232. -- use leaf decay to remove sponge air nodes
  233. default.register_leafdecay({
  234. trunks = {"ethereal:sponge_wet"},
  235. leaves = {"ethereal:sponge_air"},
  236. radius = 3
  237. })
  238. -- dry sponges can be used as fuel
  239. minetest.register_craft({
  240. type = "fuel",
  241. recipe = "ethereal:sponge",
  242. burntime = 5
  243. })