init.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. -- support for i18n
  2. local S = minetest.get_translator("youngtrees")
  3. abstract_youngtrees = {}
  4. minetest.register_node("youngtrees:bamboo", {
  5. description = S("Young Bamboo Tree"),
  6. drawtype="nodebox",
  7. tiles = {"bamboo.png"},
  8. paramtype = "light",
  9. walkable = false,
  10. is_ground_content = true,
  11. node_box = {
  12. type = "fixed",
  13. fixed = {
  14. {-0.058251,-0.500000,-0.413681,0.066749,0.500000,-0.282500}, --NodeBox 1
  15. {-0.058251,-0.500000,-0.103123,0.066749,0.500000,0.038672}, --NodeBox 2
  16. {-0.058251,-0.500000,0.181227,0.066749,0.500000,0.342500}, --NodeBox 3
  17. }
  18. },
  19. groups = {snappy=3,flammable=2},
  20. sounds = default.node_sound_leaves_defaults(),
  21. drop = 'trunks:twig_1'
  22. })
  23. minetest.register_node("youngtrees:youngtree2_middle",{
  24. description = S("Young Tree 2 (middle)"),
  25. drawtype="nodebox",
  26. tiles = {"youngtree2branch.png"},
  27. inventory_image = "youngtree2branch.png",
  28. wield_image = "youngtree2branch.png",
  29. paramtype = "light",
  30. walkable = false,
  31. is_ground_content = true,
  32. node_box = {
  33. type = "fixed",
  34. fixed = {
  35. {0.125000,-0.500000,-0.500000,0.500000,-0.187500,-0.125000}, --NodeBox 1
  36. {-0.187500,-0.187500,-0.500000,0.500000,0.125000,0.250000}, --NodeBox 2
  37. {-0.500000,0.125000,-0.500000,0.500000,0.500000,0.500000}, --NodeBox 3
  38. }
  39. },
  40. groups = {snappy=3,flammable=2},
  41. sounds = default.node_sound_leaves_defaults(),
  42. drop = 'trunks:twig_1'
  43. })
  44. minetest.register_node("youngtrees:youngtree_top", {
  45. description = S("Young Tree (top)"),
  46. drawtype = "plantlike",
  47. tiles = {"youngtree16xa.png"},
  48. inventory_image = "youngtree16xa.png",
  49. wield_image = "youngtree16xa.png",
  50. paramtype = "light",
  51. walkable = false,
  52. is_ground_content = true,
  53. selection_box = {
  54. type = "fixed",
  55. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  56. },
  57. groups = {snappy=3,flammable=2},
  58. sounds = default.node_sound_leaves_defaults(),
  59. drop = 'trunks:twig_1'
  60. })
  61. minetest.register_node("youngtrees:youngtree_middle", {
  62. description = S("Young Tree (middle)"),
  63. drawtype = "plantlike",
  64. tiles = {"youngtree16xb.png"},
  65. inventory_image = "youngtree16xb.png",
  66. wield_image = "youngtree16xb.png",
  67. paramtype = "light",
  68. walkable = false,
  69. is_ground_content = true,
  70. selection_box = {
  71. type = "fixed",
  72. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  73. },
  74. groups = {snappy=3,flammable=2},
  75. sounds = default.node_sound_leaves_defaults(),
  76. drop = 'trunks:twig_1'
  77. })
  78. minetest.register_node("youngtrees:youngtree_bottom", {
  79. description = S("Young Tree (bottom)"),
  80. drawtype = "plantlike",
  81. tiles = {"youngtree16xc.png"},
  82. inventory_image = "youngtree16xc.png",
  83. wield_image = "youngtree16xc.png",
  84. paramtype = "light",
  85. walkable = false,
  86. is_ground_content = true,
  87. selection_box = {
  88. type = "fixed",
  89. fixed = {-0.3, -0.5, -0.3, 0.3, 0.5, 0.3}
  90. },
  91. groups = {snappy=3,flammable=2},
  92. sounds = default.node_sound_leaves_defaults(),
  93. drop = 'trunks:twig_1'
  94. })
  95. abstract_youngtrees.grow_youngtree = function(pos)
  96. local height = math.random(1,3)
  97. abstract_youngtrees.grow_youngtree_node(pos,height)
  98. end
  99. abstract_youngtrees.grow_youngtree_node = function(pos, height)
  100. local right_here = {x=pos.x, y=pos.y+1, z=pos.z}
  101. local above_right_here = {x=pos.x, y=pos.y+2, z=pos.z}
  102. if minetest.get_node(right_here).name == "air" -- instead of check_air = true,
  103. or minetest.get_node(right_here).name == "default:junglegrass" then
  104. if height == 1 then
  105. minetest.swap_node(right_here, {name="youngtrees:youngtree_top"})
  106. end
  107. if height == 2 then
  108. minetest.swap_node(right_here, {name="youngtrees:youngtree_bottom"})
  109. minetest.swap_node(above_right_here, {name="youngtrees:youngtree_top"})
  110. end
  111. if height == 3 then
  112. local two_above_right_here = {x=pos.x, y=pos.y+3, z=pos.z}
  113. minetest.swap_node(right_here, {name="youngtrees:youngtree_bottom"})
  114. minetest.swap_node(above_right_here, {name="youngtrees:youngtree_middle"})
  115. minetest.swap_node(two_above_right_here, {name="youngtrees:youngtree_top"})
  116. end
  117. end
  118. end
  119. biome_lib:register_generate_plant({
  120. surface = {
  121. "default:dirt_with_grass",
  122. "stoneage:grass_with_silex",
  123. "sumpf:peat",
  124. "sumpf:sumpf"
  125. },
  126. max_count = 55, --10,15
  127. rarity = 101 - 4, --3,4
  128. min_elevation = 1, -- above sea level
  129. plantlife_limit = -0.9,
  130. },
  131. abstract_youngtrees.grow_youngtree
  132. )