mapgen.lua 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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("sunflower_8", 10, 40, nil, "", -1, farming.sunflower)
  51. register_plant("mint_4", 1, 75, {
  52. "default:dirt_with_grass", "default:dirt_with_coniferous_litter"},
  53. "group:water", 1, farming.mint)
  54. -- v6 mapgen compatibility for specific crops
  55. if mg_name == "v6" then
  56. register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
  57. register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
  58. register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
  59. register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
  60. register_plant("coffee_5", 20, 45, nil, "", -1, farming.coffee)
  61. register_plant("soy_6", 20, 50, nil, "", -1, farming.soy)
  62. else
  63. -- v7 maps have a beach so plants growing near water is limited to 6 high
  64. register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
  65. register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
  66. register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
  67. "default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
  68. register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
  69. register_plant("coffee_5", 20, 45, {"default:dirt_with_dry_grass",
  70. "default:dirt_with_rainforest_litter",
  71. "default:dry_dirt_with_dry_grass"}, "", -1, farming.coffee)
  72. register_plant("soy_6", 20, 50, {"default:dirt_with_dry_grass",
  73. "default:dirt_with_rainforest_litter",
  74. "default:dry_dirt_with_dry_grass"}, "", -1, farming.soy)
  75. end
  76. if farming.hemp then
  77. minetest.register_decoration({
  78. deco_type = "simple",
  79. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  80. sidelen = 16,
  81. noise_params = {
  82. offset = 0,
  83. scale = tonumber(farming.hemp) or farming.rarety,
  84. spread = {x = 100, y = 100, z = 100},
  85. seed = 420,
  86. octaves = 3,
  87. persist = 0.6
  88. },
  89. y_min = 3,
  90. y_max = 45,
  91. decoration = "farming:hemp_7",
  92. spawn_by = "group:tree",
  93. num_spawn_by = 1
  94. })
  95. end
  96. if farming.chili then
  97. minetest.register_decoration({
  98. deco_type = "simple",
  99. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  100. sidelen = 16,
  101. noise_params = {
  102. offset = 0,
  103. scale = tonumber(farming.chili) or farming.rarety,
  104. spread = {x = 100, y = 100, z = 100},
  105. seed = 760,
  106. octaves = 3,
  107. persist = 0.6
  108. },
  109. y_min = 5,
  110. y_max = 35,
  111. decoration = {"farming:chili_8"},
  112. spawn_by = "group:tree",
  113. num_spawn_by = 1
  114. })
  115. end
  116. if farming.artichoke then
  117. minetest.register_decoration({
  118. deco_type = "simple",
  119. place_on = {"default:dirt_with_grass"},
  120. sidelen = 16,
  121. noise_params = {
  122. offset = 0,
  123. scale = tonumber(farming.artichoke) or farming.rarety,
  124. spread = {x = 100, y = 100, z = 100},
  125. seed = 448,
  126. octaves = 3,
  127. persist = 0.6
  128. },
  129. y_min = 1,
  130. y_max = 13,
  131. decoration = {"farming:artichoke_5"},
  132. spawn_by = "group:tree",
  133. num_spawn_by = 1,
  134. })
  135. end
  136. if farming.pepper then
  137. local tmp1 = {"default:dirt_with_rainforest_litter"} -- v7
  138. if mg_name == "v6" then
  139. tmp1 = {"default:dirt_with_grass"} -- v6
  140. end
  141. minetest.register_decoration({
  142. deco_type = "simple",
  143. place_on = tmp1,
  144. sidelen = 16,
  145. noise_params = {
  146. offset = 0,
  147. scale = tonumber(farming.pepper) or farming.rarety,
  148. spread = {x = 100, y = 100, z = 100},
  149. seed = 933,
  150. octaves = 3,
  151. persist = 0.6
  152. },
  153. y_min = 5,
  154. y_max = 35,
  155. decoration = {"farming:pepper_5", "farming:pepper_6", "farming:pepper_7"},
  156. spawn_by = "group:tree",
  157. num_spawn_by = 1
  158. })
  159. end
  160. if farming.pineapple then
  161. tmp1 = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"}
  162. tmp2 = nil
  163. tmp3 = -1
  164. if mg_name == "v6" then
  165. tmp1 = {"default:dirt_with_grass"}
  166. tmp2 = "default:desert_sand"
  167. tmp3 = 1
  168. end
  169. minetest.register_decoration({
  170. deco_type = "simple",
  171. place_on = tmp1,
  172. sidelen = 16,
  173. noise_params = {
  174. offset = 0,
  175. scale = tonumber(farming.pineapple) or farming.rarety,
  176. spread = {x = 100, y = 100, z = 100},
  177. seed = 917,
  178. octaves = 3,
  179. persist = 0.6
  180. },
  181. y_min = 18,
  182. y_max = 30,
  183. decoration = {"farming:pineapple_8"},
  184. spawn_by = tmp2,
  185. num_spawn_by = tmp3
  186. })
  187. end
  188. tmp1 = {"default:dry_dirt_with_dry_grass"}
  189. tmp2 = {"savanna"}
  190. if mg_name == "v6" then
  191. tmp1 = {"default:dirt_with_grass"}
  192. tmp2 = {"jungle"}
  193. end
  194. minetest.register_decoration({
  195. name = "farming:cotton_wild",
  196. deco_type = "simple",
  197. place_on = tmp1,
  198. sidelen = 16,
  199. noise_params = {
  200. offset = -0.1,
  201. scale = 0.1,
  202. spread = {x = 50, y = 50, z = 50},
  203. seed = 4242,
  204. octaves = 3,
  205. persist = 0.7
  206. },
  207. biomes = tmp2,
  208. y_max = 31000,
  209. y_min = 1,
  210. decoration = "farming:cotton_wild"
  211. })