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. tiles = {"default_pine_needles.png"},
  44. waving = 1,
  45. paramtype = "light",
  46. is_ground_content = false,
  47. groups = basictrees.leaves_groups,
  48. drop = basictrees.get_leafdrop_table(SAPLING_CHANCE, "basictrees:pine_sapling", "basictrees:pine_needles"),
  49. sounds = default.node_sound_leaves_defaults(),
  50. movement_speed_multiplier = default.SLOW_SPEED,
  51. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  52. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="basictrees:pine_trunk"}),
  53. })
  54. minetest.register_node("basictrees:pine_sapling", {
  55. description = "Pine Tree Sapling\n\nWill not grow in deep caves.\nGrows nuts.",
  56. drawtype = "plantlike",
  57. tiles = {"default_pine_sapling.png"},
  58. inventory_image = "default_pine_sapling.png",
  59. wield_image = "default_pine_sapling.png",
  60. paramtype = "light",
  61. sunlight_propagates = true,
  62. walkable = false,
  63. selection_box = basictrees.sapling_selection_box,
  64. groups = basictrees.sapling_groups,
  65. sounds = default.node_sound_leaves_defaults(),
  66. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  67. on_timer = function(pos)
  68. if mtflower.can_grow(pos) then
  69. if mtflower.try_grow(pos, "basictrees:pine_trunk", "basictrees:pine_needles", "glowstone:minerals", "glowstone:minerals") then
  70. return
  71. end
  72. end
  73. if not basictrees.can_grow(pos) then
  74. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  75. return
  76. end
  77. local treedef = {
  78. ["angle"] = 45,
  79. ["leaves"] = "basictrees:pine_needles",
  80. ["rules_b"] = "&&GG--Gf--ffff--ffff--ffff--fff^^G&&--Gff--ff--ff--ff",
  81. ["trunk_type"] = "single",
  82. ["rules_c"] = "",
  83. ["fruit_chance"] = 10,
  84. ["fruit"] = "air",
  85. ["iterations"] = 2,
  86. ["rules_a"] = "Ta",
  87. ["random_level"] = 1,
  88. ["axiom"] = "TTa[B]TTd[B]TTd[B]Tdf",
  89. ["thin_branches"] = true,
  90. ["trunk"] = "basictrees:pine_trunk",
  91. ["leaves2_chance"] = "5",
  92. ["leaves2"] = "air",
  93. ["rules_d"] = "Td",
  94. }
  95. minetest.remove_node(pos)
  96. minetest.spawn_tree(pos, treedef)
  97. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  98. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  99. fruitscatter.scatter_fruit_under_leaves(
  100. pos,
  101. "basictrees:pine_needles",
  102. "basictrees:pine_cone",
  103. SCHEMATIC_MINP,
  104. SCHEMATIC_MAXP,
  105. math_random(6, 10)
  106. )
  107. end,
  108. on_construct = function(pos)
  109. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  110. end,
  111. on_place = function(itemstack, placer, pointed_thing)
  112. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  113. "basictrees:pine_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  114. return itemstack
  115. end,
  116. })
  117. minetest.register_node("basictrees:pine_cone", {
  118. description = "Pine Cone",
  119. drawtype = "plantlike",
  120. visual_scale = 0.8,
  121. tiles = {"moretrees_pine_cone.png"},
  122. inventory_image = "moretrees_pine_cone.png",
  123. paramtype = "light",
  124. sunlight_propagates = true,
  125. walkable = false,
  126. selection_box = {
  127. type = "fixed",
  128. fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2},
  129. },
  130. groups = {fleshy=3, dig_immediate=3, flammable=2, leafdecay=3, leafdecay_drop=1},
  131. sounds = default.node_sound_defaults(),
  132. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  133. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  134. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="basictrees:pine_trunk"}),
  135. })
  136. minetest.register_craftitem("basictrees:pine_nuts", {
  137. description = "Roasted Pine Cone Nuts",
  138. inventory_image = "moretrees_pine_nuts.png",
  139. on_use = minetest.item_eat(1),
  140. })
  141. minetest.register_craft({
  142. type = "cooking",
  143. output = "basictrees:pine_nuts 4",
  144. recipe = "basictrees:pine_cone",
  145. })
  146. minetest.register_craft({
  147. output = 'basictrees:pine_wood 4',
  148. recipe = {
  149. {'basictrees:pine_trunk'},
  150. }
  151. })
  152. minetest.register_alias("default:pine_tree", "basictrees:pine_trunk")
  153. minetest.register_alias("default:pine_needles", "basictrees:pine_needles")
  154. minetest.register_alias("default:pine_sapling", "basictrees:pine_sapling")
  155. minetest.register_alias("default:pine_wood", "basictrees:pine_wood")