sealife.lua 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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, 6)
  153. pos.y = pos.y + 1
  154. local nod = minetest.get_node(pos).name
  155. if nod == "default:water_source"
  156. and sel == 6 then
  157. minetest.swap_node(pos, {name = "ethereal:sponge_wet"})
  158. return
  159. end
  160. if nod == "default:water_source"
  161. and sel > 1 then
  162. minetest.swap_node(pos, {name = "ethereal:coral" .. sel})
  163. return
  164. end
  165. if nod == "ethereal:seaweed"
  166. or sel == 1 then
  167. local height = 0
  168. local high = 14
  169. while height < high
  170. and minetest.get_node(pos).name == "ethereal:seaweed" do
  171. height = height + 1
  172. pos.y = pos.y + 1
  173. end
  174. if pos.y < 1
  175. and height < high
  176. and minetest.get_node(pos).name == "default:water_source" then
  177. minetest.swap_node(pos, {name = "ethereal:seaweed"})
  178. end
  179. end
  180. end,
  181. })
  182. end
  183. -- sponges
  184. minetest.register_node("ethereal:sponge_air", {
  185. drawtype = "airlike",
  186. paramtype = "light",
  187. walkable = false,
  188. buildable_to = true,
  189. sunlight_propagates = true,
  190. pointable = false,
  191. drop = "",
  192. groups = {not_in_creative_inventory = 1},
  193. })
  194. minetest.register_node("ethereal:sponge", {
  195. description = S("Sponge"),
  196. tiles = {"ethereal_sponge.png"},
  197. groups = {crumbly = 3},
  198. sounds = default.node_sound_sand_defaults(),
  199. after_place_node = function(pos, placer, itemstack, pointed_thing)
  200. -- get player name
  201. local name = placer:get_player_name()
  202. -- is area protected
  203. if minetest.is_protected(pos, name) then
  204. return
  205. end
  206. -- get water nodes within range
  207. local num = minetest.find_nodes_in_area(
  208. {x = pos.x - 3, y = pos.y - 3, z = pos.z - 3},
  209. {x = pos.x + 3, y = pos.y + 3, z = pos.z + 3},
  210. {"group:water"})
  211. -- no water
  212. if #num == 0 then return end
  213. -- replace water nodes with sponge air
  214. for _, w in pairs(num) do
  215. if not minetest.is_protected(pos, name) then
  216. minetest.swap_node(w, {name = "ethereal:sponge_air"})
  217. end
  218. end
  219. -- replace dry sponge with wet sponge
  220. minetest.swap_node(pos, {name="ethereal:sponge_wet"})
  221. end
  222. })
  223. minetest.register_node("ethereal:sponge_wet", {
  224. description = S("Wet sponge"),
  225. tiles = {"ethereal_sponge_wet.png"},
  226. groups = {crumbly = 3},
  227. sounds = default.node_sound_sand_defaults(),
  228. })
  229. -- cook wet sponge into dry sponge
  230. minetest.register_craft({
  231. type = "cooking",
  232. recipe = "ethereal:sponge_wet",
  233. output = "ethereal:sponge",
  234. cooktime = 3,
  235. })
  236. -- use leaf decay to remove sponge air nodes
  237. default.register_leafdecay({
  238. trunks = {"ethereal:sponge_wet"},
  239. leaves = {"ethereal:sponge_air"},
  240. radius = 3
  241. })
  242. -- dry sponges can be used as fuel
  243. minetest.register_craft({
  244. type = "fuel",
  245. recipe = "ethereal:sponge",
  246. burntime = 5,
  247. })