init.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. local coral_color = {
  2. {'white', 'White', '#ffffff'},
  3. {'grey', 'Grey', '#808080'},
  4. {'dark_grey', 'Dark grey', '#3C3C3C'},
  5. {'black', 'Black', '#0C0C0C'},
  6. {'violet', 'Violet', '#EE82EE'},
  7. {'blue', 'Blue', '#0000FF'},
  8. {'cyan', 'Cyan', '#00FFFF'},
  9. {'dark_green', 'Dark green', '#002600'},
  10. {'green', 'Green', '#008000'},
  11. {'yellow', 'Yellow', '#FFFF00'},
  12. {'brown', 'Brown', '#A52A2A'},
  13. {'orange', 'Orange', '#FFA500'},
  14. {'red', 'Red', '#FF0000'},
  15. {'magenta', 'Magenta', '#FF00FF'},
  16. {'pink', 'Pink', '#ffc0cb'},
  17. }
  18. for i in ipairs(coral_color) do
  19. local col = coral_color[i][1]
  20. local Col = coral_color[i][2]
  21. local hex = coral_color[i][3]
  22. minetest.register_node('more_coral:coral_'..col, {
  23. description = Col..' Coral',
  24. tiles = {'more_coral_coral_base.png^[multiply:'..hex..':100'},
  25. groups = {cracky = 3, coral = 1},
  26. drops = 'default:coral_skeleton',
  27. sounds = default.node_sound_stone_defaults(),
  28. })
  29. minetest.register_craft({
  30. type = 'shapeless',
  31. output = 'more_coral:coral_'..col,
  32. recipe = {'default:coral_skeleton', 'dye:'..col},
  33. })
  34. end
  35. minetest.register_abm({ --Coral dyes when exposed to air.
  36. nodenames = {'group:coral'},
  37. neighbors = {'air'},
  38. interval = 17,
  39. chance = 5,
  40. catch_up = false,
  41. action = function(pos, node)
  42. minetest.set_node(pos, {name = 'default:coral_skeleton'})
  43. end,
  44. })
  45. minetest.register_abm({ --Coral can spread, but very slowly.
  46. nodenames = {'group:coral'},
  47. neighbors = {'group:water'},
  48. interval = 500,
  49. chance = 25,
  50. catch_up = false,
  51. action = function(pos, node)
  52. local posx = math.random(-1, 1)
  53. local posy = math.random(-1, 1)
  54. local posz = math.random(-1, 1)
  55. local new_pos = {x=pos.x+posx, y=pos.y+posy, z=pos.z+posz}
  56. local new_node = minetest.get_node(new_pos).name
  57. if minetest.get_item_group(new_node, 'water') > 0 then
  58. minetest.set_node(new_pos, {name = node.name})
  59. end
  60. end,
  61. })
  62. minetest.register_decoration({
  63. name = "default:corals",
  64. deco_type = "simple",
  65. place_on = {"default:sand"},
  66. place_offset_y = -1,
  67. sidelen = 4,
  68. noise_params = {
  69. offset = -4,
  70. scale = 4,
  71. spread = {x = 50, y = 50, z = 50},
  72. seed = 13854352,
  73. octaves = 3,
  74. persist = 0.7,
  75. },
  76. biomes = {
  77. "desert_ocean",
  78. "savanna_ocean",
  79. "rainforest_ocean",
  80. },
  81. y_max = -2,
  82. y_min = -12,
  83. flags = "force_placement",
  84. decoration = {
  85. "more_coral:coral_grey", "more_coral:coral_violet",
  86. "more_coral:coral_blue", "more_coral:coral_cyan",
  87. "more_coral:coral_green", "more_coral:coral_yellow",
  88. "more_coral:coral_pink", "more_coral:coral_red",
  89. },
  90. })