mapgen.lua 4.0 KB

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