date_palm.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. moretrees = moretrees or {}
  2. local SAPLING_TIME_MIN = 60*20
  3. local SAPLING_TIME_MAX = 60*40
  4. local SAPLING_CHANCE = 40
  5. local SCHEMATIC_MINP = {x=-4, y=0, z=-4}
  6. local SCHEMATIC_MAXP = {x=4, y=15, z=4}
  7. local SCHEMATIC_RELP = {x=-4, y=0, z=-4}
  8. minetest.register_node("moretrees:date_palm_tree", {
  9. drawtype = "nodebox",
  10. paramtype = "light",
  11. node_box = {
  12. type = "fixed",
  13. fixed = basictrees.trunk_nodebox,
  14. },
  15. description = "Date Palm Tree",
  16. tiles = {
  17. "moretrees_date_palm_trunk_top.png",
  18. "moretrees_date_palm_trunk_top.png",
  19. "moretrees_date_palm_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:date_palm_leaves",
  29. "group:dry_leaves",
  30. },
  31. }),
  32. })
  33. minetest.register_node("moretrees:date_palm_leaves", {
  34. description = "Date Palm Leaves",
  35. drawtype = "allfaces_optional",
  36. visual_scale = 1.3,
  37. tiles = {"moretrees_date_palm_leaves.png"},
  38. paramtype = "light",
  39. groups = moretrees.leaves_groups,
  40. drop = moretrees.get_leafdrop_table(SAPLING_CHANCE, "moretrees:date_palm_sapling", "moretrees:date_palm_leaves"),
  41. sounds = default.node_sound_leaves_defaults(),
  42. waving = 1,
  43. movement_speed_multiplier = default.SLOW_SPEED,
  44. on_construct = enhanced_leafdecay.make_leaf_constructor({}),
  45. on_timer = enhanced_leafdecay.make_leaf_nodetimer({tree="moretrees:date_palm_tree"}),
  46. })
  47. minetest.register_node("moretrees:date_palm_wood", {
  48. description = "Date Palm Planks",
  49. paramtype2 = "facedir",
  50. place_param2 = 0,
  51. tiles = {"moretrees_date_palm_wood.png"},
  52. groups = moretrees.get_wood_groups({wood_dark = 1}),
  53. sounds = default.node_sound_wood_defaults(),
  54. })
  55. minetest.register_node("moretrees:date_palm_sapling", {
  56. description = "Date Palm Sapling\n\nWill not grow in deep caves.",
  57. drawtype = "plantlike",
  58. --visual_scale = 1.0,
  59. tiles = {"moretrees_date_palm_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:date_palm_tree", "moretrees:date_palm_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/date_palm.mts"
  79. minetest.place_schematic(vector.add(vector.add(pos, {x=0, y=math.random(-1, 1), z=0}), SCHEMATIC_RELP), path, "random", nil, false)
  80. trunkgen.check_trunk(pos, 3, "moretrees:date_palm_tree")
  81. snowscatter.dump_snowdust_on_tree(pos, SCHEMATIC_MINP, SCHEMATIC_MAXP)
  82. ambiance.spawn_sound_beacon_inside_area("soundbeacon:trees", pos, SCHEMATIC_MINP, SCHEMATIC_MAXP, 40, 3)
  83. end,
  84. on_construct = function(pos)
  85. minetest.get_node_timer(pos):start(math.random(SAPLING_TIME_MIN, SAPLING_TIME_MAX))
  86. end,
  87. on_place = function(itemstack, placer, pointed_thing)
  88. itemstack = default.sapling_on_place(itemstack, placer, pointed_thing,
  89. "moretrees:date_palm_sapling", SCHEMATIC_MINP, SCHEMATIC_MAXP, 4)
  90. return itemstack
  91. end,
  92. })
  93. minetest.register_craft({
  94. output = 'moretrees:date_palm_wood 4',
  95. recipe = {
  96. {'moretrees:date_palm_tree'},
  97. }
  98. })
  99. minetest.register_craft({
  100. output = "default:fence_wood 4",
  101. recipe = {
  102. {"moretrees:date_palm_wood", 'group:stick', "moretrees:date_palm_wood"},
  103. {"moretrees:date_palm_wood", 'group:stick', "moretrees:date_palm_wood"},
  104. }
  105. })
  106. minetest.register_craft({
  107. output = "doors:gate_wood_closed",
  108. recipe = {
  109. {"group:stick", "moretrees:date_palm_wood", "group:stick"},
  110. {"group:stick", "moretrees:date_palm_wood", "group:stick"}
  111. }
  112. })
  113. stairs.register_stair_and_slab(
  114. "date_palm",
  115. "moretrees:date_palm_wood",
  116. moretrees.stair_groups,
  117. {"moretrees_date_palm_wood.png"},
  118. "Date Palm Plank",
  119. default.node_sound_wood_defaults()
  120. )