cedar.lua 5.9 KB

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