mapgen.lua 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. -- decoration function
  2. local function register_plant(name, min, max, spawnon, spawnby, num, rarety)
  3. -- do not place on mapgen if no value given (or not true)
  4. if not rarety then
  5. return
  6. end
  7. -- set rarety value or default to farming.rarety if not a number
  8. rarety = tonumber(rarety) or farming.rarety
  9. minetest.register_decoration({
  10. deco_type = "simple",
  11. place_on = spawnon or {"default:dirt_with_grass"},
  12. sidelen = 16,
  13. noise_params = {
  14. offset = 0,
  15. scale = rarety,
  16. spread = {x = 100, y = 100, z = 100},
  17. seed = 329,
  18. octaves = 3,
  19. persist = 0.6
  20. },
  21. y_min = min,
  22. y_max = max,
  23. decoration = "farming:" .. name,
  24. spawn_by = spawnby,
  25. num_spawn_by = num
  26. })
  27. end
  28. -- add crops to mapgen
  29. register_plant("potato_3", 15, 40, nil, "", -1, farming.potato)
  30. register_plant("tomato_7", 5, 20, nil, "", -1, farming.tomato)
  31. register_plant("corn_7", 12, 22, nil, "", -1, farming.corn)
  32. register_plant("coffee_5", 20, 45, {"default:dirt_with_dry_grass",
  33. "default:dirt_with_rainforest_litter",
  34. "default:dry_dirt_with_dry_grass"}, "", -1, farming.coffee)
  35. register_plant("raspberry_4", 3, 10, nil, "", -1, farming.raspberry)
  36. register_plant("rhubarb_3", 3, 15, nil, "", -1, farming.rhubarb)
  37. register_plant("blueberry_4", 3, 10, nil, "", -1, farming.blueberry)
  38. register_plant("beanbush", 18, 35, nil, "", -1, farming.beans)
  39. register_plant("grapebush", 25, 45, nil, "", -1, farming.grapes)
  40. register_plant("onion_5", 5, 22, nil, "", -1, farming.onion)
  41. register_plant("garlic_5", 3, 30, nil, "group:tree", 1, farming.garlic)
  42. register_plant("pea_5", 25, 50, nil, "", -1, farming.peas)
  43. register_plant("beetroot_5", 1, 15, nil, "", -1, farming.beetroot)
  44. register_plant("mint_4", 1, 75, {"default:dirt_with_grass",
  45. "default:dirt_with_coniferous_litter"}, "group:water", 1, farming.mint)
  46. register_plant("cabbage_6", 2, 10, nil, "", -1, farming.cabbage)
  47. if minetest.get_mapgen_setting("mg_name") == "v6" then
  48. register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
  49. register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
  50. register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
  51. register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
  52. else
  53. -- v7 maps have a beach so plants growing near water is limited to 6 high
  54. register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
  55. register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
  56. register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
  57. "default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
  58. register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
  59. end
  60. if farming.hemp then
  61. minetest.register_decoration({
  62. deco_type = "simple",
  63. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  64. sidelen = 16,
  65. noise_params = {
  66. offset = 0,
  67. scale = tonumber(farming.hemp) or farming.rarety,
  68. spread = {x = 100, y = 100, z = 100},
  69. seed = 420,
  70. octaves = 3,
  71. persist = 0.6
  72. },
  73. y_min = 3,
  74. y_max = 45,
  75. decoration = "farming:hemp_7",
  76. spawn_by = "group:tree",
  77. num_spawn_by = 1
  78. })
  79. end
  80. if farming.chili then
  81. minetest.register_decoration({
  82. deco_type = "simple",
  83. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  84. sidelen = 16,
  85. noise_params = {
  86. offset = 0,
  87. scale = tonumber(farming.chili) or farming.rarety,
  88. spread = {x = 100, y = 100, z = 100},
  89. seed = 760,
  90. octaves = 3,
  91. persist = 0.6
  92. },
  93. y_min = 5,
  94. y_max = 35,
  95. decoration = {"farming:chili_8"},
  96. spawn_by = "group:tree",
  97. num_spawn_by = 1
  98. })
  99. end
  100. if farming.pepper then
  101. minetest.register_decoration({
  102. deco_type = "simple",
  103. place_on = {"default:dirt_with_rainforest_litter"},
  104. sidelen = 16,
  105. noise_params = {
  106. offset = 0,
  107. scale = tonumber(farming.pepper) or farming.rarety,
  108. spread = {x = 100, y = 100, z = 100},
  109. seed = 933,
  110. octaves = 3,
  111. persist = 0.6
  112. },
  113. y_min = 5,
  114. y_max = 35,
  115. decoration = {"farming:pepper_5"},
  116. spawn_by = "group:tree",
  117. num_spawn_by = 1
  118. })
  119. end
  120. if farming.pineapple then
  121. minetest.register_decoration({
  122. deco_type = "simple",
  123. place_on = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"},
  124. sidelen = 16,
  125. noise_params = {
  126. offset = 0,
  127. scale = tonumber(farming.pineapple) or farming.rarety,
  128. spread = {x = 100, y = 100, z = 100},
  129. seed = 917,
  130. octaves = 3,
  131. persist = 0.6
  132. },
  133. y_min = 18,
  134. y_max = 30,
  135. decoration = {"farming:pineapple_8"}
  136. })
  137. end
  138. minetest.register_decoration({
  139. name = "farming:cotton_wild",
  140. deco_type = "simple",
  141. place_on = {"default:dry_dirt_with_dry_grass"},
  142. sidelen = 16,
  143. noise_params = {
  144. offset = -0.1,
  145. scale = 0.1,
  146. spread = {x = 50, y = 50, z = 50},
  147. seed = 4242,
  148. octaves = 3,
  149. persist = 0.7
  150. },
  151. biomes = {"savanna"},
  152. y_max = 31000,
  153. y_min = 1,
  154. decoration = "farming:cotton_wild"
  155. })