mapgen.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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"}, "", -1, farming.coffee)
  34. register_plant("raspberry_4", 3, 10, nil, "", -1, farming.raspberry)
  35. register_plant("rhubarb_3", 3, 15, nil, "", -1, farming.rhubarb)
  36. register_plant("blueberry_4", 3, 10, nil, "", -1, farming.blueberry)
  37. register_plant("beanbush", 18, 35, nil, "", -1, farming.beans)
  38. register_plant("grapebush", 25, 45, nil, "", -1, farming.grapes)
  39. register_plant("onion_5", 5, 22, nil, "", -1, farming.onion)
  40. register_plant("garlic_5", 3, 30, nil, "group:tree", 1, farming.garlic)
  41. register_plant("pea_5", 25, 50, nil, "", -1, farming.peas)
  42. register_plant("beetroot_5", 1, 15, nil, "", -1, farming.beetroot)
  43. register_plant("mint_4", 1, 75, {
  44. "default:dirt_with_grass", "default:dirt_with_coniferous_litter"},
  45. "group:water", 1, farming.mint)
  46. if minetest.get_mapgen_setting("mg_name") == "v6" then
  47. register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
  48. register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
  49. register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
  50. register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
  51. else
  52. -- v7 maps have a beach so plants growing near water is limited to 6 high
  53. register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
  54. register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
  55. register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
  56. "default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
  57. register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
  58. end
  59. if farming.hemp then
  60. minetest.register_decoration({
  61. deco_type = "simple",
  62. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  63. sidelen = 16,
  64. noise_params = {
  65. offset = 0,
  66. scale = tonumber(farming.hemp) or farming.rarety,
  67. spread = {x = 100, y = 100, z = 100},
  68. seed = 420,
  69. octaves = 3,
  70. persist = 0.6
  71. },
  72. y_min = 3,
  73. y_max = 45,
  74. decoration = "farming:hemp_7",
  75. spawn_by = "group:tree",
  76. num_spawn_by = 1,
  77. })
  78. end
  79. if farming.chili then
  80. minetest.register_decoration({
  81. deco_type = "simple",
  82. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  83. sidelen = 16,
  84. noise_params = {
  85. offset = 0,
  86. scale = tonumber(farming.chili) or farming.rarety,
  87. spread = {x = 100, y = 100, z = 100},
  88. seed = 760,
  89. octaves = 3,
  90. persist = 0.6
  91. },
  92. y_min = 5,
  93. y_max = 35,
  94. decoration = {"farming:chili_8"},
  95. spawn_by = "group:tree",
  96. num_spawn_by = 1,
  97. })
  98. end
  99. if farming.pepper then
  100. minetest.register_decoration({
  101. deco_type = "simple",
  102. place_on = {"default:dirt_with_rainforest_litter"},
  103. sidelen = 16,
  104. noise_params = {
  105. offset = 0,
  106. scale = tonumber(farming.pepper) or farming.rarety,
  107. spread = {x = 100, y = 100, z = 100},
  108. seed = 933,
  109. octaves = 3,
  110. persist = 0.6
  111. },
  112. y_min = 5,
  113. y_max = 35,
  114. decoration = {"farming:pepper_5"},
  115. spawn_by = "group:tree",
  116. num_spawn_by = 1,
  117. })
  118. end
  119. if farming.pineapple then
  120. minetest.register_decoration({
  121. deco_type = "simple",
  122. place_on = {"default:dirt_with_dry_grass", "default:dry_dirt_with_dry_grass"},
  123. sidelen = 16,
  124. noise_params = {
  125. offset = 0,
  126. scale = tonumber(farming.pineapple) or farming.rarety,
  127. spread = {x = 100, y = 100, z = 100},
  128. seed = 917,
  129. octaves = 3,
  130. persist = 0.6
  131. },
  132. y_min = 18,
  133. y_max = 30,
  134. decoration = {"farming:pineapple_8"},
  135. })
  136. end