pinetree.lua 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. basictrees = basictrees or {}
  2. local SAPLING_TIME_MIN = 60*15
  3. local SAPLING_TIME_MAX = 60*20
  4. local SAPLING_CHANCE = 25
  5. local SCHEMATIC_MINP = {x=-2, y=1, z=-2}
  6. local SCHEMATIC_MAXP = {x=2, y=16, z=2}
  7. local SCHEMATIC_RELP = {x=-2, y=-1, z=-2}
  8. -- Localize for performance.
  9. local math_random = math.random
  10. minetest.register_node("basictrees:pine_trunk", {
  11. drawtype = "nodebox",
  12. paramtype = "light",
  13. node_box = {
  14. type = "fixed",
  15. fixed = basictrees.trunk_nodebox,
  16. },
  17. description = "Pine Tree",
  18. tiles = {"default_pine_tree_top.png", "default_pine_tree_top.png", "default_pine_tree.png"},
  19. paramtype2 = "facedir",
  20. groups = basictrees.tree_groups,
  21. sounds = default.node_sound_wood_defaults(),
  22. on_place = minetest.rotate_node,
  23. movement_speed_multiplier = default.NORM_SPEED,
  24. on_destruct = enhanced_leafdecay.make_tree_destructor({
  25. leaves = {
  26. "basictrees:pine_cone",
  27. "basictrees:pine_needles",
  28. "group:dry_leaves",
  29. },
  30. }),
  31. })
  32. minetest.register_node("basictrees:pine_wood", {
  33. description = "Pine Wood Planks",
  34. paramtype2 = "facedir",
  35. place_param2 = 0,
  36. tiles = {"default_pine_wood.png"},
  37. groups = basictrees.get_wood_groups({wood_light = 1}),
  38. sounds = default.node_sound_wood_defaults(),
  39. })
  40. minetest.register_node("basictrees:pine_needles",{
  41. description = "Pine Needles",
  42. drawtype = "allfaces_optional",
  43. visual_scale = 1.3,
  44. tiles = {"default_pine_needles.png"},
  45. waving = 1,
  46. paramtype = "light",
  47. is_ground_content = false,
  48. groups = basictrees.leaves_groups,
  49. drop = basictrees.get_leafdrop_table(SAPLING_CHANCE, "basictrees:pine_sapling", "basictrees:pine_needles"),
  50. sounds = default.node_sound_leaves_defaults(),
  51. movement_speed_multiplier = default.SLOW_SPEED,
  52. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  53. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="basictrees:pine_trunk"}),
  54. })
  55. minetest.register_node("basictrees:pine_sapling", {
  56. description = "Pine Tree Sapling\n\nWill not grow in deep caves.\nGrows nuts.",
  57. drawtype = "plantlike",
  58. --visual_scale = 1.0,
  59. tiles = {"default_pine_sapling.png"},
  60. inventory_image = "default_pine_sapling.png",
  61. wield_image = "default_pine_sapling.png",
  62. paramtype = "light",
  63. sunlight_propagates = true,
  64. walkable = false,
  65. selection_box = basictrees.sapling_selection_box,
  66. groups = basictrees.sapling_groups,
  67. sounds = default.node_sound_leaves_defaults(),
  68. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  69. on_timer = function(pos)
  70. if mtflower.can_grow(pos) then
  71. if mtflower.try_grow(pos, "basictrees:pine_trunk", "basictrees:pine_needles", "glowstone:minerals", "glowstone:minerals") then
  72. return
  73. end
  74. end
  75. if not basictrees.can_grow(pos) then
  76. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  77. return
  78. end
  79. local treedef = {
  80. ["angle"] = 45,
  81. ["leaves"] = "basictrees:pine_needles",
  82. ["rules_b"] = "&&GG--Gf--ffff--ffff--ffff--fff^^G&&--Gff--ff--ff--ff",
  83. ["trunk_type"] = "single",
  84. ["rules_c"] = "",
  85. ["fruit_chance"] = 10,
  86. ["fruit"] = "air",
  87. ["iterations"] = 2,
  88. ["rules_a"] = "Ta",
  89. ["random_level"] = 1,
  90. ["axiom"] = "TTa[B]TTd[B]TTd[B]Tdf",
  91. ["thin_branches"] = true,
  92. ["trunk"] = "basictrees:pine_trunk",
  93. ["leaves2_chance"] = "5",
  94. ["leaves2"] = "air",
  95. ["rules_d"] = "Td",
  96. }
  97. minetest.remove_node(pos)
  98. minetest.spawn_tree(pos, treedef)
  99. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  100. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  101. fruitscatter.scatter_fruit_under_leaves(
  102. pos,
  103. "basictrees:pine_needles",
  104. "basictrees:pine_cone",
  105. SCHEMATIC_MINP,
  106. SCHEMATIC_MAXP,
  107. math_random(6, 10)
  108. )
  109. end,
  110. on_construct = function(pos)
  111. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  112. end,
  113. on_place = function(itemstack, placer, pointed_thing)
  114. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  115. "basictrees:pine_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  116. return itemstack
  117. end,
  118. })
  119. minetest.register_node("basictrees:pine_cone", {
  120. description = "Pine Cone",
  121. drawtype = "plantlike",
  122. visual_scale = 0.8,
  123. tiles = {"moretrees_pine_cone.png"},
  124. inventory_image = "moretrees_pine_cone.png",
  125. paramtype = "light",
  126. sunlight_propagates = true,
  127. walkable = false,
  128. selection_box = {
  129. type = "fixed",
  130. fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2},
  131. },
  132. groups = {fleshy=3, dig_immediate=3, flammable=2, leafdecay=3, leafdecay_drop=1},
  133. sounds = default.node_sound_defaults(),
  134. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  135. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  136. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="basictrees:pine_trunk"}),
  137. })
  138. minetest.register_craftitem("basictrees:pine_nuts", {
  139. description = "Roasted Pine Cone Nuts",
  140. inventory_image = "moretrees_pine_nuts.png",
  141. on_use = minetest.item_eat(1),
  142. })
  143. minetest.register_craft({
  144. type = "cooking",
  145. output = "basictrees:pine_nuts 4",
  146. recipe = "basictrees:pine_cone",
  147. })
  148. minetest.register_craft({
  149. output = 'basictrees:pine_wood 4',
  150. recipe = {
  151. {'basictrees:pine_trunk'},
  152. }
  153. })
  154. minetest.register_alias("default:pine_tree", "basictrees:pine_trunk")
  155. minetest.register_alias("default:pine_needles", "basictrees:pine_needles")
  156. minetest.register_alias("default:pine_sapling", "basictrees:pine_sapling")
  157. minetest.register_alias("default:pine_wood", "basictrees:pine_wood")