monuments.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. dofile(minetest.get_modpath("ocean").."/room.lua")
  2. -- mapgenv6.cpp; np_terrain_base
  3. local perl1 = {SEED1 = 82341, OCTA1 = 5, PERS1 = 0.6, SCAL1 = 250}
  4. minetest.register_node("ocean:prismarine", {
  5. description = "Prismarine",
  6. drawtype = "normal",
  7. tiles = {"prismarine.png"},
  8. groups = {cracky=2,level=1},
  9. sounds = default.node_sound_stone_defaults(),
  10. })
  11. minetest.register_node("ocean:dark_prismarine", {
  12. description = "Dark Prismarine",
  13. drawtype = "normal",
  14. tiles = {"prismarine_dark.png"},
  15. groups = {cracky=2,level=1},
  16. sounds = default.node_sound_stone_defaults(),
  17. })
  18. minetest.register_node("ocean:prismarine_bricks", {
  19. description = "Prismarine Bricks",
  20. drawtype = "normal",
  21. tiles = {"prismarine_bricks.png"},
  22. groups = {cracky=2,level=1},
  23. sounds = default.node_sound_stone_defaults(),
  24. })
  25. minetest.register_node("ocean:sea_lantern", {
  26. description = "Sea Lantern",
  27. tiles = {"sea_lantern.png"},
  28. light_source = 14,
  29. drop = {
  30. max_items = 1,
  31. items = {
  32. {items = {'ocean:prismarine_crystals 3'}, rarity = 15},
  33. {items = {'ocean:prismarine_crystals 4'}, rarity = 20},
  34. {items = {'ocean:prismarine_crystals 5'}, rarity = 25},
  35. {items = {'ocean:sea_lantern'}},
  36. },
  37. },
  38. groups = {cracky=3,oddly_breakable_by_hand=3},
  39. sounds = default.node_sound_glass_defaults(),
  40. })
  41. minetest.register_craftitem("ocean:prismarine_crystals", {
  42. description = "Prismarine Crystals",
  43. inventory_image = "prismarine_crystals.png",
  44. })
  45. minetest.register_craftitem("ocean:prismarine_shard", {
  46. description = "Prismarine Shard",
  47. inventory_image = "prismarine_shard.png",
  48. })
  49. minetest.register_craft({
  50. output = 'ocean:sea_lantern',
  51. recipe = {
  52. {'ocean:prismarine_shard', 'ocean:prismarine_crystals', 'ocean:prismarine_shard'},
  53. {'ocean:prismarine_crystals', 'ocean:prismarine_crystals', 'ocean:prismarine_crystals'},
  54. {'ocean:prismarine_shard', 'ocean:prismarine_crystals', 'ocean:prismarine_shard'},
  55. }
  56. })
  57. minetest.register_craft({
  58. output = 'ocean:prismarine_bricks',
  59. recipe = {
  60. {'ocean:prismarine_shard', 'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  61. {'ocean:prismarine_shard', 'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  62. {'ocean:prismarine_shard', 'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  63. }
  64. })
  65. minetest.register_craft({
  66. output = 'ocean:dark_prismarine',
  67. recipe = {
  68. {'ocean:prismarine_shard', 'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  69. {'ocean:prismarine_shard', 'dye:black', 'ocean:prismarine_shard'},
  70. {'ocean:prismarine_shard', 'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  71. }
  72. })
  73. minetest.register_craft({
  74. output = 'ocean:prismarine',
  75. recipe = {
  76. {'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  77. {'ocean:prismarine_shard', 'ocean:prismarine_shard'},
  78. }
  79. })
  80. minetest.register_craft({
  81. output = 'ocean:prismarine_shard 4',
  82. recipe = {
  83. {'ocean:prismarine'},
  84. }
  85. })
  86. local function hlp_fnct(pos, name)
  87. local n = minetest.get_node_or_nil(pos)
  88. if n and n.name and n.name == name then
  89. return true
  90. else
  91. return false
  92. end
  93. end
  94. local function ground(pos, old)
  95. local p2 = pos
  96. while hlp_fnct(p2, "default:water_source") do
  97. p2.y = p2.y - 1
  98. end
  99. if p2.y < old.y then
  100. return p2
  101. else
  102. return old
  103. end
  104. end
  105. local function make_entrance(pos)
  106. local gang = {x=pos.x+10,y=pos.y, z=pos.z}
  107. for iy=2,3,1 do
  108. for iz=0,6,1 do
  109. minetest.set_node({x=gang.x+1,y=gang.y+iy,z=gang.z+iz}, {name = "default:water_source"})
  110. if iz >=3 and iy == 3 then
  111. minetest.set_node({x=gang.x,y=gang.y+iy+1,z=gang.z+iz}, {name="ocean:prismarine_bricks"})
  112. minetest.set_node({x=gang.x+1,y=gang.y+iy+1,z=gang.z+iz}, {name="ocean:prismarine_bricks"})
  113. minetest.set_node({x=gang.x+2,y=gang.y+iy+1,z=gang.z+iz}, {name="ocean:prismarine_bricks"})
  114. end
  115. end
  116. end
  117. end
  118. local function make(pos)
  119. minetest.log("action", "Created ocean monument at ("..pos.x..","..pos.y..","..pos.z..")")
  120. for iy=0,10,1 do
  121. for ix=iy,22-iy,1 do
  122. for iz=iy,22-iy,1 do
  123. if iy <1 then minetest.set_node({x=pos.x+ix,y=pos.y,z=pos.z+iz}, {name="ocean:prismarine"}) end
  124. if ix == iy or ix == 22-iy or iz == iy or iz == 22-iy then
  125. minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="ocean:prismarine_bricks"})
  126. else
  127. minetest.set_node({x=pos.x+ix,y=pos.y+iy,z=pos.z+iz}, {name="ocean:prismarine"})
  128. end
  129. end
  130. end
  131. end
  132. minetest.set_node({x=pos.x+10,y=pos.y+11,z=pos.z+10}, {name="ocean:sea_lantern"})
  133. minetest.set_node({x=pos.x+12,y=pos.y+11,z=pos.z+12}, {name="ocean:sea_lantern"})
  134. minetest.set_node({x=pos.x+10,y=pos.y+11,z=pos.z+12}, {name="ocean:sea_lantern"})
  135. minetest.set_node({x=pos.x+12,y=pos.y+11,z=pos.z+10}, {name="ocean:sea_lantern"})
  136. ocean.make_room(pos)
  137. minetest.after(2, ocean.make_pillars, pos)
  138. make_entrance({x=pos.x,y=pos.y, z=pos.z})
  139. end
  140. minetest.register_on_generated(function(minp, maxp, seed)
  141. if minp.y > 0 then return end
  142. math.randomseed(seed)
  143. local cnt = 0
  144. local perlin1 = minetest.get_perlin(perl1.SEED1, perl1.OCTA1, perl1.PERS1, perl1.SCAL1)
  145. local noise1 = perlin1:get_2d({x=minp.x,y=minp.y})--,z=minp.z})
  146. if noise1 < -.2 then
  147. local mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  148. local p2 = minetest.find_node_near(mpos, 25, {"default:dirt","default:sand","default:desert_sand","default:stone"})
  149. while p2 == nil and cnt < 5 do
  150. cnt = cnt+1
  151. mpos = {x=math.random(minp.x,maxp.x), y=math.random(minp.y,maxp.y), z=math.random(minp.z,maxp.z)}
  152. p2 = minetest.find_node_near(mpos, 25, {"default:dirt","default:sand","default:desert_sand","default:stone"})
  153. end
  154. if p2 == nil then return end
  155. if p2.y > 0 then return end
  156. local off = 0
  157. local opos1 = {x=p2.x+22,y=p2.y-1,z=p2.z+22}
  158. local opos2 = {x=p2.x+22,y=p2.y-1,z=p2.z}
  159. local opos3 = {x=p2.x, y=p2.y-1,z=p2.z+22}
  160. local opos1_n = minetest.get_node_or_nil(opos1)
  161. local opos2_n = minetest.get_node_or_nil(opos2)
  162. local opos3_n = minetest.get_node_or_nil(opos3)
  163. if opos1_n and opos1_n.name and opos1_n.name == "default:water_source" then
  164. p2 = ground(opos1, p2)
  165. elseif opos2_n and opos2_n.name and opos2_n.name == "default:water_source" then
  166. p2 = ground(opos2, p2)
  167. elseif opos3_n and opos3_n.name and opos3_n.name == "default:water_source" then
  168. p2 = ground(opos3, p2)
  169. end
  170. if minetest.find_node_near({x=p2.x,y=0,z=p2.z}, 22, {"default:dirt_with_grass"}) or minetest.find_node_near({x=p2.x,y=0,z=p2.z}, 80, {"ocean:prismarine"}) then return end
  171. if minetest.find_node_near({x=p2.x,y=-2,z=p2.z}, 2, {"default:water_source"}) and minetest.find_node_near({x=p2.x+20,y=-2,z=p2.z+20}, 2, {"default:water_source"}) then
  172. local raise = math.floor(-p2.y/3)
  173. if raise > 10 then raise = 10 end
  174. p2.y = p2.y + raise
  175. if p2.y > -35 and p2.y < -5 then minetest.after(0.8,make,p2) end
  176. end
  177. end
  178. end)