Vanessa's plantlife modpack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
6.5KB

  1. -----------------------------------------------------------------------------------------------
  2. -- Ferns - Tree Fern 0.1.1
  3. -----------------------------------------------------------------------------------------------
  4. -- by Mossmanikin
  5. -- License (everything): WTFPL
  6. -- Contains code from: biome_lib
  7. -- Looked at code from: default , trees
  8. -----------------------------------------------------------------------------------------------
  9. assert(abstract_ferns.config.enable_treefern == true)
  10. abstract_ferns.grow_tree_fern = function(pos)
  11. local pos_01 = {x = pos.x, y = pos.y + 1, z = pos.z}
  12. if minetest.get_node(pos_01).name ~= "air"
  13. and minetest.get_node(pos_01).name ~= "ferns:sapling_tree_fern"
  14. and minetest.get_node(pos_01).name ~= "default:junglegrass" then
  15. return
  16. end
  17. local size = math.random(1, 4) + math.random(1, 4)
  18. if (size > 5) then
  19. size = 10 - size
  20. end
  21. size = size + 1
  22. local crown = ({ "ferns:tree_fern_leaves", "ferns:tree_fern_leaves_02" })[math.random(1, 2)]
  23. local i = 1
  24. while (i < size-1) do
  25. if minetest.get_node({x = pos.x, y = pos.y + i + 1, z = pos.z}).name ~= "air" then
  26. break
  27. end
  28. minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = "ferns:fern_trunk" })
  29. i = i + 1
  30. end
  31. minetest.set_node({x = pos.x, y = pos.y + i, z = pos.z}, { name = crown })
  32. end
  33. -----------------------------------------------------------------------------------------------
  34. -- TREE FERN LEAVES
  35. -----------------------------------------------------------------------------------------------
  36. -- TODO: Both of these nodes look the same?
  37. minetest.register_node("ferns:tree_fern_leaves", {
  38. description = "Tree Fern Crown (Dicksonia)",
  39. drawtype = "plantlike",
  40. visual_scale = 2,
  41. paramtype = "light",
  42. paramtype2 = "facedir",
  43. --tiles = {"[combine:32x32:0,0=top_left.png:0,16=bottom_left.png:16,0=top_right.png:16,16=bottom_right.png"},
  44. tiles = {"ferns_fern_tree.png"},
  45. inventory_image = "ferns_fern_tree_inv.png",
  46. walkable = false,
  47. groups = {snappy=3,flammable=2,attached_node=1},
  48. drop = {
  49. max_items = 2,
  50. items = {
  51. {
  52. -- occasionally, drop a second sapling instead of leaves
  53. -- (extra saplings can also be obtained by replanting and
  54. -- reharvesting leaves)
  55. items = {"ferns:sapling_tree_fern"},
  56. rarity = 10,
  57. },
  58. {
  59. items = {"ferns:sapling_tree_fern"},
  60. },
  61. {
  62. items = {"ferns:tree_fern_leaves"},
  63. }
  64. }
  65. },
  66. sounds = default.node_sound_leaves_defaults(),
  67. selection_box = {
  68. type = "fixed",
  69. fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
  70. },
  71. })
  72. minetest.register_node("ferns:tree_fern_leaves_02", {
  73. drawtype = "plantlike",
  74. visual_scale = 2,
  75. paramtype = "light",
  76. tiles = {"ferns_fern_big.png"},
  77. walkable = false,
  78. groups = {snappy=3,flammable=2,attached_node=1,not_in_creative_inventory=1},
  79. drop = {
  80. max_items = 2,
  81. items = {
  82. {
  83. -- occasionally, drop a second sapling instead of leaves
  84. -- (extra saplings can also be obtained by replanting and
  85. -- reharvesting leaves)
  86. items = {"ferns:sapling_tree_fern"},
  87. rarity = 10,
  88. },
  89. {
  90. items = {"ferns:sapling_tree_fern"},
  91. },
  92. {
  93. items = {"ferns:tree_fern_leaves"},
  94. }
  95. }
  96. },
  97. sounds = default.node_sound_leaves_defaults(),
  98. selection_box = {
  99. type = "fixed",
  100. fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
  101. },
  102. })
  103. -----------------------------------------------------------------------------------------------
  104. -- FERN TRUNK
  105. -----------------------------------------------------------------------------------------------
  106. minetest.register_node("ferns:fern_trunk", {
  107. description = "Fern Trunk (Dicksonia)",
  108. drawtype = "nodebox",
  109. paramtype = "light",
  110. tiles = {
  111. "ferns_fern_trunk_top.png",
  112. "ferns_fern_trunk_top.png",
  113. "ferns_fern_trunk.png"
  114. },
  115. node_box = {
  116. type = "fixed",
  117. fixed = {-1/8, -1/2, -1/8, 1/8, 1/2, 1/8},
  118. },
  119. selection_box = {
  120. type = "fixed",
  121. fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7},
  122. },
  123. groups = {tree=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
  124. sounds = default.node_sound_wood_defaults(),
  125. after_destruct = function(pos,oldnode)
  126. local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
  127. if node.name == "ferns:fern_trunk" then
  128. minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
  129. minetest.add_item(pos,"ferns:fern_trunk")
  130. end
  131. end,
  132. })
  133. -----------------------------------------------------------------------------------------------
  134. -- TREE FERN SAPLING
  135. -----------------------------------------------------------------------------------------------
  136. minetest.register_node("ferns:sapling_tree_fern", {
  137. description = "Tree Fern Sapling (Dicksonia)",
  138. drawtype = "plantlike",
  139. paramtype = "light",
  140. paramtype2 = "facedir",
  141. tiles = {"ferns_sapling_tree_fern.png"},
  142. inventory_image = "ferns_sapling_tree_fern.png",
  143. walkable = false,
  144. groups = {snappy=3,flammable=2,flora=1,attached_node=1},
  145. sounds = default.node_sound_leaves_defaults(),
  146. selection_box = {
  147. type = "fixed",
  148. fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
  149. },
  150. })
  151. -- abm
  152. minetest.register_abm({
  153. nodenames = "ferns:sapling_tree_fern",
  154. interval = 1000,
  155. chance = 4,
  156. action = function(pos, node, _, _)
  157. abstract_ferns.grow_tree_fern({x = pos.x, y = pos.y-1, z = pos.z})
  158. end
  159. })
  160. -----------------------------------------------------------------------------------------------
  161. -- GENERATE TREE FERN
  162. -----------------------------------------------------------------------------------------------
  163. -- in jungles
  164. if abstract_ferns.config.enable_treeferns_in_jungle == true then
  165. biome_lib:register_generate_plant({
  166. surface = {
  167. "default:dirt_with_grass",
  168. "default:sand",
  169. "default:desert_sand",
  170. },
  171. max_count = 35,--27,
  172. avoid_nodes = {"default:tree"},
  173. avoid_radius = 4,
  174. rarity = 50,
  175. seed_diff = 329,
  176. min_elevation = -10,
  177. near_nodes = {"default:jungletree"},
  178. near_nodes_size = 6,
  179. near_nodes_vertical = 2,--4,
  180. near_nodes_count = 1,
  181. plantlife_limit = -0.9,
  182. humidity_max = -1.0,
  183. humidity_min = 0.4,
  184. temp_max = -0.5,
  185. temp_min = 0.13,
  186. },
  187. abstract_ferns.grow_tree_fern
  188. )
  189. end
  190. -- for oases & tropical beaches
  191. if abstract_ferns.config.enable_treeferns_in_oases == true then
  192. biome_lib:register_generate_plant({
  193. surface = {
  194. "default:sand"--,
  195. --"default:desert_sand"
  196. },
  197. max_count = 35,
  198. rarity = 50,
  199. seed_diff = 329,
  200. neighbors = {"default:desert_sand"},
  201. ncount = 1,
  202. min_elevation = 1,
  203. near_nodes = {"default:water_source"},
  204. near_nodes_size = 2,
  205. near_nodes_vertical = 1,
  206. near_nodes_count = 1,
  207. plantlife_limit = -0.9,
  208. humidity_max = -1.0,
  209. humidity_min = 1.0,
  210. temp_max = -1.0,
  211. temp_min = 1.0,
  212. },
  213. abstract_ferns.grow_tree_fern
  214. )
  215. end