mapgen.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. -- what mapgen are we using
  2. local mg_name = minetest.get_mapgen_setting("mg_name")
  3. -- temp vars
  4. local tmp1, tmp2, tmp3
  5. -- decoration function
  6. local function register_plant(name, min, max, spawnon, spawnby, num, rarety)
  7. -- do not place on mapgen if no value given (or not true)
  8. if not rarety then
  9. return
  10. end
  11. -- set rarety value or default to farming.rarety if not a number
  12. rarety = tonumber(rarety) or farming.rarety
  13. minetest.register_decoration({
  14. deco_type = "simple",
  15. place_on = spawnon or {"default:dirt_with_grass"},
  16. sidelen = 16,
  17. noise_params = {
  18. offset = 0,
  19. scale = rarety,
  20. spread = {x = 100, y = 100, z = 100},
  21. seed = 329,
  22. octaves = 3,
  23. persist = 0.6
  24. },
  25. y_min = min,
  26. y_max = max,
  27. decoration = "farming:" .. name,
  28. spawn_by = spawnby,
  29. num_spawn_by = num
  30. })
  31. end
  32. -- add crops to mapgen
  33. register_plant("potato_3", 15, 40, nil, "", -1, farming.potato)
  34. register_plant("tomato_7", 5, 20, nil, "", -1, farming.tomato)
  35. register_plant("corn_7", 12, 22, nil, "", -1, farming.corn)
  36. register_plant("raspberry_4", 3, 10, nil, "", -1, farming.raspberry)
  37. register_plant("rhubarb_3", 3, 15, nil, "", -1, farming.rhubarb)
  38. register_plant("blueberry_4", 3, 10, nil, "", -1, farming.blueberry)
  39. register_plant("beanbush", 18, 35, nil, "", -1, farming.beans)
  40. register_plant("grapebush", 25, 45, nil, "", -1, farming.grapes)
  41. register_plant("onion_5", 5, 22, nil, "", -1, farming.onion)
  42. register_plant("garlic_5", 3, 30, nil, "group:tree", 1, farming.garlic)
  43. register_plant("pea_5", 25, 50, nil, "", -1, farming.peas)
  44. register_plant("beetroot_5", 1, 15, nil, "", -1, farming.beetroot)
  45. register_plant("cabbage_6", 2, 10, nil, "", -1, farming.cabbage)
  46. register_plant("lettuce_5", 5, 30, nil, "", -1, farming.lettuce)
  47. register_plant("blackberry_4", 3, 10, nil, "", -1, farming.blackberry)
  48. register_plant("vanilla_7", 5, 35, nil, "", -1, farming.vanilla)
  49. register_plant("parsley_3", 10, 40, nil, "", -1, farming.parsley)
  50. register_plant("mint_4", 1, 75, {
  51. "default:dirt_with_grass", "default:dirt_with_coniferous_litter"},
  52. "group:water", 1, farming.mint)
  53. -- v6 mapgen compatibility for specific crops
  54. if mg_name == "v6" then
  55. register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
  56. register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
  57. register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
  58. register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
  59. register_plant("coffee_5", 20, 45, nil, "", -1, farming.coffee)
  60. register_plant("soy_6", 20, 50, nil, "", -1, farming.soy)
  61. else
  62. -- v7 maps have a beach so plants growing near water is limited to 6 high
  63. register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
  64. register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
  65. register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
  66. "default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
  67. register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
  68. register_plant("coffee_5", 20, 45, {"default:dirt_with_dry_grass",
  69. "default:dirt_with_rainforest_litter",
  70. "default:dry_dirt_with_dry_grass"}, "", -1, farming.coffee)
  71. register_plant("soy_6", 20, 50, {"default:dirt_with_dry_grass",
  72. "default:dirt_with_rainforest_litter",
  73. "default:dry_dirt_with_dry_grass"}, "", -1, farming.soy)
  74. end
  75. if farming.hemp then
  76. minetest.register_decoration({
  77. deco_type = "simple",
  78. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  79. sidelen = 16,
  80. noise_params = {
  81. offset = 0,
  82. scale = tonumber(farming.hemp) or farming.rarety,
  83. spread = {x = 100, y = 100, z = 100},
  84. seed = 420,
  85. octaves = 3,
  86. persist = 0.6
  87. },
  88. y_min = 3,
  89. y_max = 45,
  90. decoration = "farming:hemp_7",
  91. spawn_by = "group:tree",
  92. num_spawn_by = 1
  93. })
  94. end
  95. if farming.chili then
  96. minetest.register_decoration({
  97. deco_type = "simple",
  98. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  99. sidelen = 16,
  100. noise_params = {
  101. offset = 0,
  102. scale = tonumber(farming.chili) or farming.rarety,
  103. spread = {x = 100, y = 100, z = 100},
  104. seed = 760,
  105. octaves = 3,
  106. persist = 0.6
  107. },
  108. y_min = 5,
  109. y_max = 35,
  110. decoration = {"farming:chili_8"},
  111. spawn_by = "group:tree",
  112. num_spawn_by = 1
  113. })
  114. end
  115. if farming.artichoke then
  116. minetest.register_decoration({
  117. deco_type = "simple",
  118. place_on = {"default:dirt_with_grass"},
  119. sidelen = 16,
  120. noise_params = {
  121. offset = 0,
  122. scale = tonumber(farming.artichoke) or farming.rarety,
  123. spread = {x = 100, y = 100, z = 100},
  124. seed = 448,
  125. octaves = 3,
  126. persist = 0.6
  127. },
  128. y_min = 1,
  129. y_max = 13,
  130. decoration = {"farming:artichoke_5"},
  131. spawn_by = "group:tree",
  132. num_spawn_by = 1,
  133. })
  134. end
  135. if farming.pepper then
  136. local tmp1 = {"default:dirt_with_rainforest_litter"} -- v7
  137. if mg_name == "v6" then
  138. tmp1 = {"default:dirt_with_grass"} -- v6
  139. end
  140. minetest.register_decoration({
  141. deco_type = "simple",
  142. place_on = tmp1,
  143. sidelen = 16,
  144. noise_params = {
  145. offset = 0,
  146. scale = tonumber(farming.pepper) or farming.rarety,
  147. spread = {x = 100, y = 100, z = 100},
  148. seed = 933,
  149. octaves = 3,
  150. persist = 0.6
  151. },
  152. y_min = 5,
  153. y_max = 35,
  154. decoration = {"farming:pepper_5", "farming:pepper_6", "farming:pepper_7"},
  155. spawn_by = "group:tree",
  156. num_spawn_by = 1
  157. })
  158. end
  159. if farming.pineapple then
  160. tmp1 = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"}
  161. tmp2 = nil
  162. tmp3 = -1
  163. if mg_name == "v6" then
  164. tmp1 = {"default:dirt_with_grass"}
  165. tmp2 = "default:desert_sand"
  166. tmp3 = 1
  167. end
  168. minetest.register_decoration({
  169. deco_type = "simple",
  170. place_on = tmp1,
  171. sidelen = 16,
  172. noise_params = {
  173. offset = 0,
  174. scale = tonumber(farming.pineapple) or farming.rarety,
  175. spread = {x = 100, y = 100, z = 100},
  176. seed = 917,
  177. octaves = 3,
  178. persist = 0.6
  179. },
  180. y_min = 18,
  181. y_max = 30,
  182. decoration = {"farming:pineapple_8"},
  183. spawn_by = tmp2,
  184. num_spawn_by = tmp3
  185. })
  186. end
  187. tmp1 = {"default:dry_dirt_with_dry_grass"}
  188. tmp2 = {"savanna"}
  189. if mg_name == "v6" then
  190. tmp1 = {"default:dirt_with_grass"}
  191. tmp2 = {"jungle"}
  192. end
  193. minetest.register_decoration({
  194. name = "farming:cotton_wild",
  195. deco_type = "simple",
  196. place_on = tmp1,
  197. sidelen = 16,
  198. noise_params = {
  199. offset = -0.1,
  200. scale = 0.1,
  201. spread = {x = 50, y = 50, z = 50},
  202. seed = 4242,
  203. octaves = 3,
  204. persist = 0.7
  205. },
  206. biomes = tmp2,
  207. y_max = 31000,
  208. y_min = 1,
  209. decoration = "farming:cotton_wild"
  210. })