mapgen.lua 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. register_plant("lettuce_5", 5, 30, nil, "", -1, farming.lettuce)
  48. register_plant("blackberry_4", 3, 10, nil, "", -1, farming.blackberry)
  49. register_plant("soy_6", 20, 50, {"default:dirt_with_dry_grass",
  50. "default:dirt_with_rainforest_litter",
  51. "default:dry_dirt_with_dry_grass"}, "", -1, farming.soy)
  52. register_plant("vanilla_7", 5, 35, nil, "", -1, farming.vanilla)
  53. if minetest.get_mapgen_setting("mg_name") == "v6" then
  54. register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
  55. register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
  56. register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
  57. register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
  58. else
  59. -- v7 maps have a beach so plants growing near water is limited to 6 high
  60. register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
  61. register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
  62. register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
  63. "default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
  64. register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
  65. end
  66. if farming.hemp then
  67. minetest.register_decoration({
  68. deco_type = "simple",
  69. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  70. sidelen = 16,
  71. noise_params = {
  72. offset = 0,
  73. scale = tonumber(farming.hemp) or farming.rarety,
  74. spread = {x = 100, y = 100, z = 100},
  75. seed = 420,
  76. octaves = 3,
  77. persist = 0.6
  78. },
  79. y_min = 3,
  80. y_max = 45,
  81. decoration = "farming:hemp_7",
  82. spawn_by = "group:tree",
  83. num_spawn_by = 1
  84. })
  85. end
  86. if farming.chili then
  87. minetest.register_decoration({
  88. deco_type = "simple",
  89. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  90. sidelen = 16,
  91. noise_params = {
  92. offset = 0,
  93. scale = tonumber(farming.chili) or farming.rarety,
  94. spread = {x = 100, y = 100, z = 100},
  95. seed = 760,
  96. octaves = 3,
  97. persist = 0.6
  98. },
  99. y_min = 5,
  100. y_max = 35,
  101. decoration = {"farming:chili_8"},
  102. spawn_by = "group:tree",
  103. num_spawn_by = 1
  104. })
  105. end
  106. if farming.pepper then
  107. minetest.register_decoration({
  108. deco_type = "simple",
  109. place_on = {"default:dirt_with_rainforest_litter"},
  110. sidelen = 16,
  111. noise_params = {
  112. offset = 0,
  113. scale = tonumber(farming.pepper) or farming.rarety,
  114. spread = {x = 100, y = 100, z = 100},
  115. seed = 933,
  116. octaves = 3,
  117. persist = 0.6
  118. },
  119. y_min = 5,
  120. y_max = 35,
  121. decoration = {"farming:pepper_5", "farming:pepper_6", "farming:pepper_7"},
  122. spawn_by = "group:tree",
  123. num_spawn_by = 1
  124. })
  125. end
  126. if farming.pineapple then
  127. minetest.register_decoration({
  128. deco_type = "simple",
  129. place_on = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"},
  130. sidelen = 16,
  131. noise_params = {
  132. offset = 0,
  133. scale = tonumber(farming.pineapple) or farming.rarety,
  134. spread = {x = 100, y = 100, z = 100},
  135. seed = 917,
  136. octaves = 3,
  137. persist = 0.6
  138. },
  139. y_min = 18,
  140. y_max = 30,
  141. decoration = {"farming:pineapple_8"}
  142. })
  143. end
  144. minetest.register_decoration({
  145. name = "farming:cotton_wild",
  146. deco_type = "simple",
  147. place_on = {"default:dry_dirt_with_dry_grass"},
  148. sidelen = 16,
  149. noise_params = {
  150. offset = -0.1,
  151. scale = 0.1,
  152. spread = {x = 50, y = 50, z = 50},
  153. seed = 4242,
  154. octaves = 3,
  155. persist = 0.7
  156. },
  157. biomes = {"savanna"},
  158. y_max = 31000,
  159. y_min = 1,
  160. decoration = "farming:cotton_wild"
  161. })