aspentree.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. basictrees = basictrees or {}
  2. local SAPLING_TIME_MIN = 60*15
  3. local SAPLING_TIME_MAX = 60*25
  4. local SAPLING_CHANCE = 20
  5. local SCHEMATIC_MINP = {x=-2, y=1, z=-2}
  6. local SCHEMATIC_MAXP = {x=2, y=12, z=2}
  7. local SCHEMATIC_RELP = {x=-2, y=-1, z=-2}
  8. minetest.register_node("basictrees:aspen_trunk", {
  9. drawtype = "nodebox",
  10. paramtype = "light",
  11. node_box = {
  12. type = "fixed",
  13. fixed = basictrees.trunk_nodebox,
  14. },
  15. description = "Aspen Tree",
  16. tiles = {"default_aspen_tree_top.png", "default_aspen_tree_top.png", "default_aspen_tree.png"},
  17. paramtype2 = "facedir",
  18. groups = basictrees.tree_groups,
  19. sounds = default.node_sound_wood_defaults(),
  20. on_place = minetest.rotate_node,
  21. movement_speed_multiplier = default.NORM_SPEED,
  22. on_destruct = enhanced_leafdecay.make_tree_destructor({
  23. leaves = {
  24. "basictrees:aspen_leaves",
  25. "group:dry_leaves",
  26. },
  27. }),
  28. })
  29. minetest.register_node("basictrees:aspen_wood", {
  30. description = "Aspen Wood Planks",
  31. paramtype2 = "facedir",
  32. place_param2 = 0,
  33. tiles = {"default_aspen_wood.png"},
  34. groups = basictrees.get_wood_groups({wood_light = 1}),
  35. sounds = default.node_sound_wood_defaults(),
  36. })
  37. minetest.register_node("basictrees:aspen_leaves", {
  38. description = "Aspen Leaves",
  39. drawtype = "allfaces_optional",
  40. visual_scale = 1.3,
  41. tiles = {"default_aspen_leaves.png"},
  42. waving = 1,
  43. paramtype = "light",
  44. groups = basictrees.leaves_groups,
  45. drop = basictrees.get_leafdrop_table(SAPLING_CHANCE, "basictrees:aspen_sapling", "basictrees:aspen_leaves"),
  46. sounds = default.node_sound_leaves_defaults(),
  47. movement_speed_multiplier = default.SLOW_SPEED,
  48. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  49. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="basictrees:aspen_trunk"}),
  50. })
  51. minetest.register_node("basictrees:aspen_sapling", {
  52. description = "Aspen Tree Sapling\n\nWill not grow in deep caves.",
  53. drawtype = "plantlike",
  54. --visual_scale = 1.0,
  55. tiles = {"default_aspen_sapling.png"},
  56. inventory_image = "default_aspen_sapling.png",
  57. wield_image = "default_aspen_sapling.png",
  58. paramtype = "light",
  59. sunlight_propagates = true,
  60. walkable = false,
  61. selection_box = basictrees.sapling_selection_box,
  62. groups = basictrees.sapling_groups,
  63. sounds = default.node_sound_leaves_defaults(),
  64. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  65. on_timer = function(pos)
  66. if mtflower.can_grow(pos) then
  67. if mtflower.try_grow(pos, "basictrees:aspen_trunk", "basictrees:aspen_leaves", "glowstone:minerals", "glowstone:minerals") then
  68. return
  69. end
  70. end
  71. if not basictrees.can_grow(pos) then
  72. minetest.get_node_timer(pos):start(math.random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  73. return
  74. end
  75. local path = basictrees.modpath .. "/schematics/aspen_tree_from_sapling.mts"
  76. minetest.place_schematic(vector.add(pos, SCHEMATIC_RELP), path, "random", nil, false)
  77. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  78. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  79. end,
  80. on_construct = function(pos)
  81. minetest.get_node_timer(pos):start(math.random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  82. end,
  83. on_place = function(itemstack, placer, pointed_thing)
  84. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  85. "basictrees:aspen_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  86. return itemstack
  87. end,
  88. })
  89. minetest.register_craft({
  90. output = 'basictrees:aspen_wood 4',
  91. recipe = {
  92. {'basictrees:aspen_trunk'},
  93. }
  94. })
  95. minetest.register_alias("default:aspen_tree", "basictrees:aspen_trunk")
  96. minetest.register_alias("default:aspen_leaves", "basictrees:aspen_leaves")
  97. minetest.register_alias("default:aspen_wood", "basictrees:aspen_wood")
  98. minetest.register_alias("default:aspen_sapling", "basictrees:aspen_sapling")