fir.lua 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. moretrees = moretrees or {}
  2. local SAPLING_TIME_MIN = 60*20
  3. local SAPLING_TIME_MAX = 60*30
  4. local SAPLING_CHANCE = 40
  5. local SCHEMATIC_MINP = {x=-3, y=0, z=-3}
  6. local SCHEMATIC_MAXP = {x=3, y=14, z=3}
  7. local SCHEMATIC_RELP = {x=-3, y=0, z=-3}
  8. minetest.register_node("moretrees:fir_tree", {
  9. drawtype = "nodebox",
  10. paramtype = "light",
  11. node_box = {
  12. type = "fixed",
  13. fixed = basictrees.trunk_nodebox,
  14. },
  15. description = "Fir Tree",
  16. tiles = {
  17. "moretrees_fir_trunk_top.png",
  18. "moretrees_fir_trunk_top.png",
  19. "moretrees_fir_trunk.png"
  20. },
  21. paramtype2 = "facedir",
  22. groups = moretrees.tree_groups,
  23. sounds = default.node_sound_wood_defaults(),
  24. on_place = minetest.rotate_node,
  25. movement_speed_multiplier = default.NORM_SPEED,
  26. on_destruct = enhanced_leafdecay.make_tree_destructor({
  27. leaves = {
  28. "moretrees:fir_leaves",
  29. "moretrees:fir_cone",
  30. "group:dry_leaves",
  31. },
  32. }),
  33. })
  34. minetest.register_node("moretrees:fir_leaves", {
  35. description = "Fir Leaves",
  36. drawtype = "allfaces_optional",
  37. visual_scale = 1.3,
  38. tiles = {"moretrees_fir_leaves.png"},
  39. paramtype = "light",
  40. groups = moretrees.leaves_groups,
  41. drop = moretrees.get_leafdrop_table(SAPLING_CHANCE, "moretrees:fir_sapling", "moretrees:fir_leaves"),
  42. sounds = default.node_sound_leaves_defaults(),
  43. waving = 1,
  44. movement_speed_multiplier = default.SLOW_SPEED,
  45. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  46. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="moretrees:fir_tree"}),
  47. })
  48. minetest.register_node("moretrees:fir_wood", {
  49. description = "Fir Planks",
  50. paramtype2 = "facedir",
  51. place_param2 = 0,
  52. tiles = {"moretrees_fir_wood.png"},
  53. groups = moretrees.get_wood_groups({wood_light = 1}),
  54. sounds = default.node_sound_wood_defaults(),
  55. })
  56. minetest.register_node("moretrees:fir_sapling", {
  57. description = "Fir Sapling\n\nWill not grow in deep caves.\nGrows nuts.",
  58. drawtype = "plantlike",
  59. --visual_scale = 1.0,
  60. tiles = {"moretrees_fir_sapling.png"},
  61. paramtype = "light",
  62. sunlight_propagates = true,
  63. walkable = false,
  64. selection_box = moretrees.sapling_selection_box,
  65. groups = moretrees.sapling_groups,
  66. sounds = default.node_sound_leaves_defaults(),
  67. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  68. on_timer = function(pos, elapsed)
  69. if mtflower.can_grow(pos) then
  70. if mtflower.try_grow(pos, "moretrees:fir_tree", "moretrees:fir_leaves", "glowstone:minerals", "glowstone:minerals") then
  71. return
  72. end
  73. end
  74. if not moretrees.can_grow(pos) then
  75. minetest.get_node_timer(pos):start(math.random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  76. return
  77. end
  78. minetest.set_node(pos, {name='air'}) -- Remove sapling first.
  79. local path = moretrees.modpath .. "/schematics/fir.mts"
  80. minetest.place_schematic(vector.add(vector.add(pos, {x=0, y=math.random(-1, 1), z=0}), SCHEMATIC_RELP), path, "random", nil, false)
  81. trunkgen.check_trunk(pos, 3, "moretrees:fir_tree")
  82. hb4.leafscatter.remove(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, "moretrees:fir_leaves", math.random(10, 30))
  83. hb4.leafscatter.add(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, "moretrees:fir_leaves", math.random(10, 30))
  84. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  85. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  86. fruitscatter.scatter_fruit_under_leaves(
  87. pos,
  88. "moretrees:fir_leaves",
  89. "moretrees:fir_cone",
  90. SCHEMATIC_MINP,
  91. SCHEMATIC_MAXP,
  92. math.random(6, 10)
  93. )
  94. end,
  95. on_construct = function(pos)
  96. minetest.get_node_timer(pos):start(math.random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  97. end,
  98. on_place = function(itemstack, placer, pointed_thing)
  99. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  100. "moretrees:fir_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  101. return itemstack
  102. end,
  103. })
  104. minetest.register_node("moretrees:fir_cone", {
  105. description = "Fir Cone",
  106. drawtype = "plantlike",
  107. visual_scale = 0.8,
  108. tiles = {"moretrees_fir_cone.png"},
  109. inventory_image = "moretrees_fir_cone.png",
  110. paramtype = "light",
  111. sunlight_propagates = true,
  112. walkable = false,
  113. selection_box = {
  114. type = "fixed",
  115. fixed = {-0.2, -0.5, -0.2, 0.2, 0, 0.2},
  116. },
  117. groups = {fleshy=3, dig_immediate=3, flammable=2, leafdecay=3, leafdecay_drop=1},
  118. sounds = default.node_sound_defaults(),
  119. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  120. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  121. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="moretrees:fir_tree"}),
  122. after_dig_node = hb4.fruitregrow.after_dig_node(),
  123. after_place_node = hb4.fruitregrow.after_place_node(),
  124. on_finish_collapse = hb4.fruitregrow.on_finish_collapse(),
  125. })
  126. minetest.register_craftitem("moretrees:fir_nuts", {
  127. description = "Roasted Fir Cone Nuts",
  128. inventory_image = "moretrees_fir_nuts.png",
  129. on_use = minetest.item_eat(1),
  130. -- Nuts do not rot.
  131. })
  132. minetest.register_craft({
  133. type = "cooking",
  134. output = "moretrees:fir_nuts 4",
  135. recipe = "moretrees:fir_cone",
  136. })
  137. minetest.register_craft({
  138. output = 'moretrees:fir_wood 4',
  139. recipe = {
  140. {'moretrees:fir_tree'},
  141. }
  142. })
  143. minetest.register_craft({
  144. output = "default:fence_wood 4",
  145. recipe = {
  146. {"moretrees:fir_wood", 'group:stick', "moretrees:fir_wood"},
  147. {"moretrees:fir_wood", 'group:stick', "moretrees:fir_wood"},
  148. }
  149. })
  150. minetest.register_craft({
  151. output = "doors:gate_wood_closed",
  152. recipe = {
  153. {"group:stick", "moretrees:fir_wood", "group:stick"},
  154. {"group:stick", "moretrees:fir_wood", "group:stick"}
  155. }
  156. })
  157. stairs.register_stair_and_slab(
  158. "fir",
  159. "moretrees:fir_wood",
  160. moretrees.stair_groups,
  161. {"moretrees_fir_wood.png"},
  162. "Fir Plank",
  163. default.node_sound_wood_defaults()
  164. )