mapgen.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. -- decoration function
  2. local function register_plant(name, min, max, spawnon, spawnby, num, enabled)
  3. if enabled ~= true then
  4. return
  5. end
  6. minetest.register_decoration({
  7. deco_type = "simple",
  8. place_on = spawnon or {"default:dirt_with_grass"},
  9. sidelen = 16,
  10. noise_params = {
  11. offset = 0,
  12. scale = farming.rarety, -- 0.006,
  13. spread = {x = 100, y = 100, z = 100},
  14. seed = 329,
  15. octaves = 3,
  16. persist = 0.6
  17. },
  18. y_min = min,
  19. y_max = max,
  20. decoration = "farming:" .. name,
  21. spawn_by = spawnby,
  22. num_spawn_by = num,
  23. })
  24. end
  25. -- add crops to mapgen
  26. register_plant("potato_3", 15, 40, nil, "", -1, farming.potato)
  27. register_plant("tomato_7", 5, 20, nil, "", -1, farming.tomato)
  28. register_plant("corn_7", 12, 22, nil, "", -1, farming.corn)
  29. register_plant("coffee_5", 20, 45, {"default:dirt_with_dry_grass",
  30. "default:dirt_with_rainforest_litter"}, "", -1, farming.coffee)
  31. register_plant("raspberry_4", 3, 10, nil, "", -1, farming.raspberry)
  32. register_plant("rhubarb_3", 3, 15, nil, "", -1, farming.rhubarb)
  33. register_plant("blueberry_4", 3, 10, nil, "", -1, farming.blueberry)
  34. register_plant("beanbush", 18, 35, nil, "", -1, farming.beans)
  35. register_plant("grapebush", 25, 45, nil, "", -1, farming.grapes)
  36. register_plant("onion_5", 5, 22, nil, "", -1, farming.onion)
  37. register_plant("garlic_5", 3, 30, nil, "group:tree", 1, farming.garlic)
  38. register_plant("pea_5", 25, 50, nil, "", -1, farming.peas)
  39. register_plant("beetroot_5", 1, 15, nil, "", -1, farming.beetroot)
  40. if minetest.get_mapgen_setting("mg_name") == "v6" then
  41. register_plant("carrot_8", 1, 30, nil, "group:water", 1, farming.carrot)
  42. register_plant("cucumber_4", 1, 20, nil, "group:water", 1, farming.cucumber)
  43. register_plant("melon_8", 1, 20, nil, "group:water", 1, farming.melon)
  44. register_plant("pumpkin_8", 1, 20, nil, "group:water", 1, farming.pumpkin)
  45. else
  46. -- v7 maps have a beach so plants growing near water is limited to 6 high
  47. register_plant("carrot_8", 1, 15, nil, "", -1, farming.carrot)
  48. register_plant("cucumber_4", 1, 10, nil, "", -1, farming.cucumber)
  49. register_plant("melon_8", 1, 6, {"default:dirt_with_dry_grass",
  50. "default:dirt_with_rainforest_litter"}, "", -1, farming.melon)
  51. register_plant("pumpkin_8", 1, 6, nil, "", -1, farming.pumpkin)
  52. end
  53. if farming.hemp then
  54. minetest.register_decoration({
  55. deco_type = "simple",
  56. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  57. sidelen = 16,
  58. noise_params = {
  59. offset = 0,
  60. scale = farming.rarety, -- 0.06,
  61. spread = {x = 100, y = 100, z = 100},
  62. seed = 420,
  63. octaves = 3,
  64. persist = 0.6
  65. },
  66. y_min = 3,
  67. y_max = 45,
  68. decoration = "farming:hemp_7",
  69. spawn_by = "group:tree",
  70. num_spawn_by = 1,
  71. })
  72. end
  73. if farming.chili then
  74. minetest.register_decoration({
  75. deco_type = "simple",
  76. place_on = {"default:dirt_with_grass", "default:dirt_with_rainforest_litter"},
  77. sidelen = 16,
  78. noise_params = {
  79. offset = 0,
  80. scale = farming.rarety, -- 0.06,
  81. spread = {x = 100, y = 100, z = 100},
  82. seed = 760,
  83. octaves = 3,
  84. persist = 0.6
  85. },
  86. y_min = 5,
  87. y_max = 35,
  88. decoration = {"farming:chili_8"},
  89. spawn_by = "group:tree",
  90. num_spawn_by = 1,
  91. })
  92. end
  93. if farming.pepper then
  94. minetest.register_decoration({
  95. deco_type = "simple",
  96. place_on = {"default:dirt_with_rainforest_litter"},
  97. sidelen = 16,
  98. noise_params = {
  99. offset = 0,
  100. scale = farming.rarety, -- 0.06,
  101. spread = {x = 100, y = 100, z = 100},
  102. seed = 933,
  103. octaves = 3,
  104. persist = 0.6
  105. },
  106. y_min = 5,
  107. y_max = 35,
  108. decoration = {"farming:pepper_5"},
  109. spawn_by = "group:tree",
  110. num_spawn_by = 1,
  111. })
  112. end
  113. if farming.pineapple then
  114. minetest.register_decoration({
  115. deco_type = "simple",
  116. place_on = {"default:dirt_with_dry_grass"},
  117. sidelen = 16,
  118. noise_params = {
  119. offset = 0,
  120. scale = farming.rarety, -- 0.06,
  121. spread = {x = 100, y = 100, z = 100},
  122. seed = 917,
  123. octaves = 3,
  124. persist = 0.6
  125. },
  126. y_min = 18,
  127. y_max = 30,
  128. decoration = {"farming:pineapple_8"},
  129. })
  130. end