deco.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. local water_level = minetest.get_mapgen_setting("water_level")
  2. minetest.set_gen_notify("dungeon")
  3. minetest.register_on_generated(function(minp, maxp, seed)
  4. if minp.y < (water_level-1250)
  5. or minp.y > (water_level-250) then
  6. return
  7. end
  8. local c_air = minetest.get_content_id("air")
  9. local c_mossycobble = minetest.get_content_id("default:mossycobble")
  10. local c_tomb_1 = minetest.get_content_id("lottblocks:dwarf_tomb_bottom")
  11. local c_tomb_2 = minetest.get_content_id("lottblocks:dwarf_tomb_top")
  12. local c_gold = minetest.get_content_id("default:goldblock")
  13. local notify = minetest.get_mapgen_object("gennotify")
  14. if notify ~= nil then
  15. if notify.dungeon ~= nil then
  16. local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
  17. local area = VoxelArea:new{MinEdge=emin, MaxEdge=emax}
  18. local data = vm:get_data()
  19. local c = 0
  20. for k,v in pairs(notify.dungeon) do
  21. local center = {x=v.x,y=v.y,z=v.z}
  22. local ycheck = {x=center.x,y=center.y,z=center.z}
  23. local i = area:indexp(ycheck)
  24. c = 0
  25. while data[i] == d_air and c < 25 do
  26. ycheck.y = ycheck.y + 1
  27. i = area:indexp(ycheck)
  28. c = c + 1
  29. end
  30. ycheck.y = ycheck.y - 1
  31. local height = ( ycheck.y - center.y )
  32. local xcheck = {x=center.x,y=center.y,z=center.z}
  33. local i = area:indexp(xcheck)
  34. c = 0
  35. while data[i] == d_air and c < 25 do
  36. xcheck.x = xcheck.x + 1
  37. i = area:indexp(xcheck)
  38. c = c + 1
  39. end
  40. xcheck.x = xcheck.x - 1
  41. local zcheck = {x=center.x,y=center.y,z=center.z}
  42. local i = area:indexp(zcheck)
  43. c = 0
  44. while data[i] == d_air and c < 25 do
  45. zcheck.z = zcheck.z + 1
  46. i = area:indexp(zcheck)
  47. c = c + 1
  48. end
  49. zcheck.z = zcheck.z - 1
  50. local xsize = ( xcheck.x - center.x )
  51. local zsize = ( zcheck.z - center.z )
  52. if math.random(50) == 1 then
  53. local vi = area:indexp({x=zcheck.x,y=(zcheck.y),z=(zcheck.z+1)})
  54. data[vi] = c_tomb_1
  55. vi = area:indexp({x=zcheck.x,y=(zcheck.y),z=(zcheck.z+2)})
  56. data[vi] = c_tomb_2
  57. vi = area:indexp({x=zcheck.x,y=(zcheck.y-1),z=(zcheck.z+1)})
  58. data[vi] = c_gold
  59. vi = area:indexp({x=zcheck.x,y=(zcheck.y-1),z=(zcheck.z+2)})
  60. data[vi] = c_gold
  61. end
  62. end
  63. vm:set_data(data)
  64. vm:calc_lighting()
  65. vm:write_to_map(data)
  66. end
  67. end
  68. end)
  69. -- Buildings
  70. minetest.register_decoration({
  71. deco_type = "schematic",
  72. place_on = "default:snowblock",
  73. sidelen = 16,
  74. fill_ratio = 0.004,
  75. schematic = minetest.get_modpath("lottmapgen").."/schems/abandoned_fort.mts",
  76. flags = "place_center_x, place_center_z",
  77. })
  78. minetest.register_decoration({
  79. deco_type = "schematic",
  80. place_on = "default:snowblock",
  81. sidelen = 16,
  82. fill_ratio = 0.0045,
  83. schematic = minetest.get_modpath("lottmapgen").."/schems/abandoned_tower.mts",
  84. flags = "place_center_x, place_center_z",
  85. })