mapgen.lua 4.1 KB

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