sequoia.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. moretrees = moretrees or {}
  2. local SAPLING_TIME_MIN = 60*25
  3. local SAPLING_TIME_MAX = 60*60
  4. local SAPLING_CHANCE = 40
  5. local SCHEMATIC_MINP = {x=-3, y=0, z=-3}
  6. local SCHEMATIC_MAXP = {x=3, y=21, z=3}
  7. local SCHEMATIC_RELP = {x=-3, y=0, z=-3}
  8. -- Localize for performance.
  9. local math_random = math.random
  10. minetest.register_node("moretrees:sequoia_tree", {
  11. drawtype = "nodebox",
  12. paramtype = "light",
  13. node_box = {
  14. type = "fixed",
  15. fixed = basictrees.trunk_nodebox,
  16. },
  17. description = "Sequoia Tree",
  18. tiles = {
  19. "moretrees_sequoia_trunk_top.png",
  20. "moretrees_sequoia_trunk_top.png",
  21. "moretrees_sequoia_trunk.png"
  22. },
  23. paramtype2 = "facedir",
  24. groups = moretrees.tree_groups,
  25. sounds = default.node_sound_wood_defaults(),
  26. on_place = minetest.rotate_node,
  27. movement_speed_multiplier = default.NORM_SPEED,
  28. on_destruct = enhanced_leafdecay.make_tree_destructor({
  29. leaves = {
  30. "moretrees:sequoia_leaves",
  31. "group:dry_leaves",
  32. },
  33. }),
  34. })
  35. minetest.register_node("moretrees:sequoia_leaves", {
  36. description = "Sequoia Leaves",
  37. drawtype = "allfaces_optional",
  38. tiles = {"moretrees_sequoia_leaves.png"},
  39. paramtype = "light",
  40. waving = 1,
  41. groups = moretrees.leaves_groups,
  42. drop = moretrees.get_leafdrop_table(SAPLING_CHANCE, "moretrees:sequoia_sapling", "moretrees:sequoia_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({tree="moretrees:sequoia_tree"}),
  47. })
  48. minetest.register_node("moretrees:sequoia_wood", {
  49. description = "Sequoia Planks",
  50. paramtype2 = "facedir",
  51. place_param2 = 0,
  52. tiles = {"moretrees_sequoia_wood.png"},
  53. groups = moretrees.get_wood_groups({wood_dark = 1}),
  54. sounds = default.node_sound_wood_defaults(),
  55. })
  56. minetest.register_node("moretrees:sequoia_sapling", {
  57. description = "Sequoia Sapling\n\nWill not grow in deep caves.",
  58. drawtype = "plantlike",
  59. tiles = {"moretrees_sequoia_sapling.png"},
  60. paramtype = "light",
  61. sunlight_propagates = true,
  62. walkable = false,
  63. selection_box = moretrees.sapling_selection_box,
  64. groups = moretrees.sapling_groups,
  65. sounds = default.node_sound_leaves_defaults(),
  66. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  67. on_timer = function(pos, elapsed)
  68. if mtflower.can_grow(pos) then
  69. if mtflower.try_grow(pos, "moretrees:sequoia_tree", "moretrees:sequoia_leaves", "glowstone:minerals", "glowstone:minerals") then
  70. return
  71. end
  72. end
  73. if not moretrees.can_grow(pos) then
  74. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  75. return
  76. end
  77. minetest.set_node(pos, {name='air'}) -- Remove sapling first.
  78. local path = moretrees.modpath .. "/schematics/sequoia.mts"
  79. minetest.place_schematic(vector.add(vector.add(pos, {x=0, y=math_random(-2, 1), z=0}), SCHEMATIC_RELP), path, "random", nil, false)
  80. trunkgen.check_trunk(pos, 3, "moretrees:sequoia_tree")
  81. hb4.leafscatter.remove(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, "moretrees:sequoia_leaves", math_random(10, 30))
  82. hb4.leafscatter.add(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, "moretrees:sequoia_leaves", math_random(10, 30))
  83. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  84. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  85. end,
  86. on_construct = function(pos)
  87. minetest.get_node_timer(pos):start(math_random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  88. end,
  89. on_place = function(itemstack, placer, pointed_thing)
  90. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  91. "moretrees:sequoia_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  92. return itemstack
  93. end,
  94. })
  95. minetest.register_craft({
  96. output = 'moretrees:sequoia_wood 4',
  97. recipe = {
  98. {'moretrees:sequoia_tree'},
  99. }
  100. })
  101. minetest.register_craft({
  102. output = "default:fence_wood 4",
  103. recipe = {
  104. {"moretrees:sequoia_wood", 'group:stick', "moretrees:sequoia_wood"},
  105. {"moretrees:sequoia_wood", 'group:stick', "moretrees:sequoia_wood"},
  106. }
  107. })
  108. minetest.register_craft({
  109. output = "doors:gate_wood_closed",
  110. recipe = {
  111. {"techcrafts:hinge_wood", "moretrees:sequoia_wood", "group:stick"},
  112. {"group:stick", "moretrees:sequoia_wood", "group:stick"}
  113. }
  114. })
  115. stairs.register_stair_and_slab(
  116. "sequoia",
  117. "moretrees:sequoia_wood",
  118. moretrees.stair_groups,
  119. {"moretrees_sequoia_wood.png"},
  120. "Sequoia Plank",
  121. default.node_sound_wood_defaults()
  122. )