horsetail.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. -----------------------------------------------------------------------------------------------
  2. -- Archae Plantae - Horsetail 0.0.5
  3. -----------------------------------------------------------------------------------------------
  4. -- by Mossmanikin
  5. -- Contains code from: biome_lib
  6. -- Looked at code from: default, flowers, trees
  7. -- Dependencies: biome_lib
  8. -- Supports: dryplants, stoneage, sumpf
  9. -----------------------------------------------------------------------------------------------
  10. assert(abstract_ferns.config.enable_horsetails == true)
  11. -- support for i18n
  12. local S = minetest.get_translator("ferns")
  13. -----------------------------------------------------------------------------------------------
  14. -- HORSETAIL (EQUISETUM)
  15. -----------------------------------------------------------------------------------------------
  16. local node_names = {}
  17. local function create_nodes()
  18. local selection_boxes = {
  19. { -0.15, -1/2, -0.15, 0.15, -1/16, 0.15 },
  20. { -0.15, -1/2, -0.15, 0.15, 1/16, 0.15 },
  21. { -0.15, -1/2, -0.15, 0.15, 4/16, 0.15 },
  22. { -0.15, -1/2, -0.15, 0.15, 7/16, 0.15 },
  23. }
  24. for i = 1, 4 do
  25. local node_name = "ferns:horsetail_" .. string.format("%02d", i)
  26. local node_img = "ferns_horsetail_" .. string.format("%02d", i) .. ".png"
  27. local node_desc
  28. local node_on_use = nil
  29. local node_drop = "ferns:horsetail_04"
  30. if i == 1 then
  31. node_desc = S("Young Horsetail (Equisetum)")
  32. node_on_use = minetest.item_eat(1) -- young ones edible https://en.wikipedia.org/wiki/Equisetum
  33. node_drop = node_name
  34. elseif i == 4 then
  35. node_desc = S("Horsetail (Equisetum)")
  36. else
  37. node_desc = S("Horsetail (Equisetum)").." ".. string.format("%02d", i)
  38. end
  39. node_names[i] = node_name
  40. minetest.register_node(node_name, {
  41. description = node_desc,
  42. drawtype = "plantlike",
  43. paramtype = "light",
  44. tiles = { node_img },
  45. inventory_image = node_img,
  46. walkable = false,
  47. buildable_to = true,
  48. groups = {snappy=3,flammable=2,attached_node=1,horsetail=1},
  49. sounds = default.node_sound_leaves_defaults(),
  50. selection_box = {
  51. type = "fixed",
  52. fixed = selection_boxes[i],
  53. },
  54. on_use = node_on_use,
  55. drop = node_drop,
  56. })
  57. end
  58. end
  59. -----------------------------------------------------------------------------------------------
  60. -- Init
  61. -----------------------------------------------------------------------------------------------
  62. create_nodes()
  63. -----------------------------------------------------------------------------------------------
  64. -- Spawning
  65. -----------------------------------------------------------------------------------------------
  66. if abstract_ferns.config.enable_horsetails_spawning == true then
  67. biome_lib:spawn_on_surfaces({
  68. spawn_delay = 1200,
  69. spawn_plants = node_names,
  70. spawn_chance = 400,
  71. spawn_surfaces = {
  72. "default:dirt_with_grass",
  73. "default:dirt_with_coniferous_litter", -- minetest >= 0.5
  74. "default:desert_sand",
  75. "default:sand",
  76. "dryplants:grass_short",
  77. "stoneage:grass_with_silex",
  78. "default:mossycobble",
  79. "default:gravel"
  80. },
  81. seed_diff = 329,
  82. min_elevation = 1, -- above sea level
  83. near_nodes = {"default:water_source","default:river_water_source","default:gravel"},
  84. near_nodes_size = 2,
  85. near_nodes_vertical = 1,
  86. near_nodes_count = 1,
  87. --random_facedir = { 0, 179 },
  88. })
  89. end
  90. -----------------------------------------------------------------------------------------------
  91. -- Generating
  92. -----------------------------------------------------------------------------------------------
  93. if abstract_ferns.config.enable_horsetails_on_grass == true then
  94. biome_lib:register_generate_plant({
  95. surface = {
  96. "default:dirt_with_grass",
  97. "default:dirt_with_coniferous_litter", -- minetest >= 0.5
  98. "sumpf:sumpf"
  99. },
  100. max_count = 35,
  101. rarity = 40,
  102. min_elevation = 1, -- above sea level
  103. near_nodes = {
  104. "group:water", -- likes water (of course)
  105. "default:gravel", -- near those on gravel
  106. "default:sand", -- some like sand
  107. "default:clay", -- some like clay
  108. "stoneage:grass_with_silex",
  109. "default:mossycobble",
  110. "default:cobble",
  111. "sumpf:sumpf"
  112. },
  113. near_nodes_size = 3,
  114. near_nodes_vertical = 2,--3,
  115. near_nodes_count = 1,
  116. plantlife_limit = -0.9,
  117. humidity_min = 0.4,
  118. temp_max = -0.5, -- 55 °C
  119. temp_min = 0.53, -- 0 °C, dies back in winter
  120. --random_facedir = { 0, 179 },
  121. },
  122. node_names
  123. )
  124. end
  125. if abstract_ferns.config.enable_horsetails_on_stones == true then
  126. biome_lib:register_generate_plant({
  127. surface = {
  128. "default:gravel", -- roots go deep
  129. "default:mossycobble",
  130. "stoneage:dirt_with_silex",
  131. "stoneage:grass_with_silex",
  132. "stoneage:sand_with_silex", -- roots go deep
  133. },
  134. max_count = 35,
  135. rarity = 20,
  136. min_elevation = 1, -- above sea level
  137. plantlife_limit = -0.9,
  138. humidity_min = 0.4,
  139. temp_max = -0.5, -- 55 °C
  140. temp_min = 0.53, -- 0 °C, dies back in winter
  141. --random_facedir = { 0, 179 },
  142. },
  143. node_names
  144. )
  145. end