generating.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. -- generating of forest soils
  2. local RaDiuS = {
  3. -- WE1 NS1 WE2 NS2 WE3 NS3
  4. {-1,-2, -2,-2, -2,-3},
  5. { 0,-2, -3,-1, -3,-2},
  6. { 1,-2, -3, 0, -4,-1},
  7. {-2,-1, -3, 1, -4, 0},
  8. {-1,-1, -2, 2, -4, 1},
  9. { 0,-1, -1, 3, -3, 2},
  10. { 1,-1, 0, 3, -2, 3},
  11. { 2,-1, 1, 3, -1, 4},
  12. {-2, 0, 2, 2, 0, 4},
  13. {-1, 0, 3, 1, 1, 4},
  14. { 0, 0, 3, 0, 2, 3},
  15. { 1, 0, 3,-1, 3, 2},
  16. { 2, 0, 2,-2, 4, 1},
  17. {-2, 1, 1,-3, 4, 0},
  18. {-1, 1, 0,-3, 4,-1},
  19. { 0, 1, -1,-3, 3,-2},
  20. { 1, 1, 0, 0, 2,-3},
  21. { 2, 1, 0, 0, 1,-4},
  22. {-1, 2, 0, 0, 0,-4},
  23. { 0, 2, 0, 0, -1,-4},
  24. { 1, 2, 0, 0, 0, 0},
  25. }
  26. -- e = + , n = +
  27. abstract_woodsoils.place_soil = function(pos)
  28. if minetest.get_item_group(minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name, "soil") > 0
  29. or minetest.get_item_group(minetest.get_node({x=pos.x,y=pos.y-2,z=pos.z}).name, "soil") > 0 then
  30. for i in pairs(RaDiuS) do
  31. local WE1 = RaDiuS[i][1]
  32. local NS1 = RaDiuS[i][2]
  33. local WE2 = RaDiuS[i][3]
  34. local NS2 = RaDiuS[i][4]
  35. local WE3 = RaDiuS[i][5]
  36. local NS3 = RaDiuS[i][6]
  37. local radius_1a = {x=pos.x+WE1,y=pos.y-1,z=pos.z+NS1}
  38. local radius_1b = {x=pos.x+WE1,y=pos.y-2,z=pos.z+NS1}
  39. local radius_2a = {x=pos.x+WE2,y=pos.y-1,z=pos.z+NS2}
  40. local radius_2b = {x=pos.x+WE2,y=pos.y-2,z=pos.z+NS2}
  41. local radius_3a = {x=pos.x+WE3,y=pos.y-1,z=pos.z+NS3}
  42. local radius_3b = {x=pos.x+WE3,y=pos.y-2,z=pos.z+NS3}
  43. --local node_1a = minetest.get_node(radius_1a)
  44. --local node_1b = minetest.get_node(radius_1b)
  45. local node_2a = minetest.get_node(radius_2a)
  46. local node_2b = minetest.get_node(radius_2b)
  47. local node_3a = minetest.get_node(radius_3a)
  48. local node_3b = minetest.get_node(radius_3b)
  49. -- Dirt with Leaves 1
  50. if minetest.get_item_group(minetest.get_node(radius_1a).name, "soil") > 0 then
  51. minetest.swap_node(radius_1a, {name="woodsoils:dirt_with_leaves_1"})
  52. end
  53. if minetest.get_item_group(minetest.get_node(radius_1b).name, "soil") > 0 then
  54. minetest.swap_node(radius_1b, {name="woodsoils:dirt_with_leaves_1"})
  55. end
  56. -- Grass with Leaves 2
  57. if string.find(node_2a.name, "dirt_with_grass") then
  58. minetest.swap_node(radius_2a, {name="woodsoils:grass_with_leaves_2"})
  59. end
  60. if string.find(node_2b.name, "dirt_with_grass") then
  61. minetest.swap_node(radius_2b, {name="woodsoils:grass_with_leaves_2"})
  62. end
  63. -- Grass with Leaves 1
  64. if string.find(node_3a.name, "dirt_with_grass") then
  65. minetest.swap_node(radius_3a, {name="woodsoils:grass_with_leaves_1"})
  66. end
  67. if string.find(node_3b.name, "dirt_with_grass") then
  68. minetest.swap_node(radius_3b, {name="woodsoils:grass_with_leaves_1"})
  69. end
  70. end
  71. end
  72. end
  73. biome_lib:register_generate_plant({
  74. surface = {
  75. "group:tree",
  76. "ferns:fern_03",
  77. "ferns:fern_02",
  78. "ferns:fern_01"
  79. },
  80. max_count = 1000,
  81. rarity = 1,
  82. min_elevation = 1,
  83. max_elevation = 40,
  84. near_nodes = {"group:tree","ferns:fern_03","ferns:fern_02","ferns:fern_01"},
  85. near_nodes_size = 5,
  86. near_nodes_vertical = 1,
  87. near_nodes_count = 4,
  88. plantlife_limit = -1,
  89. check_air = false,
  90. },
  91. "abstract_woodsoils.place_soil"
  92. )
  93. biome_lib:register_generate_plant({
  94. surface = {
  95. "moretrees:apple_tree_sapling_ongen",
  96. "moretrees:beech_sapling_ongen",
  97. "moretrees:birch_sapling_ongen",
  98. "moretrees:fir_sapling_ongen",
  99. "moretrees:jungletree_sapling_ongen",
  100. "moretrees:oak_sapling_ongen",
  101. "moretrees:palm_sapling_ongen",
  102. "moretrees:rubber_tree_sapling_ongen",
  103. "moretrees:sequoia_sapling_ongen",
  104. "moretrees:spruce_sapling_ongen",
  105. "moretrees:willow_sapling_ongen"
  106. },
  107. max_count = 1000,
  108. rarity = 2,
  109. min_elevation = 1,
  110. max_elevation = 40,
  111. plantlife_limit = -0.9,
  112. check_air = false,
  113. },
  114. "abstract_woodsoils.place_soil"
  115. )
  116. minetest.register_abm({
  117. nodenames = {"default:papyrus"},
  118. neighbors = {
  119. "woodsoils:dirt_with_leaves_1",
  120. "woodsoils:dirt_with_leaves_2",
  121. "woodsoils:grass_with_leaves_1",
  122. "woodsoils:grass_with_leaves_2"
  123. },
  124. interval = 50,
  125. chance = 20,
  126. action = function(pos, node)
  127. pos.y = pos.y-1
  128. local name = minetest.get_node(pos).name
  129. if string.find(name, "_with_leaves_") then
  130. if minetest.find_node_near(pos, 3, {"group:water"}) == nil then
  131. return
  132. end
  133. pos.y = pos.y+1
  134. local height = 0
  135. while minetest.get_node(pos).name == "default:papyrus" and height < 4 do
  136. height = height+1
  137. pos.y = pos.y+1
  138. end
  139. if height < 4 then
  140. if minetest.get_node(pos).name == "air" then
  141. minetest.swap_node(pos, {name="default:papyrus"})
  142. end
  143. end
  144. end
  145. end,
  146. })