init.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. -- If any trees get added to the game, consider extending this list.
  2. local all_trees = {
  3. {trunk="basictrees:acacia_trunk"},
  4. {trunk="basictrees:aspen_trunk"},
  5. {trunk="basictrees:jungletree_trunk"},
  6. {trunk="basictrees:pine_trunk"},
  7. {trunk="basictrees:tree_trunk"},
  8. {trunk="jungletree:jungletree_tree"},
  9. {trunk="firetree:trunk"},
  10. {trunk="moretrees:apple_tree_tree"},
  11. {trunk="moretrees:beech_tree"},
  12. {trunk="moretrees:birch_tree"},
  13. {trunk="moretrees:cedar_tree"},
  14. {trunk="moretrees:date_palm_tree"},
  15. {trunk="moretrees:fir_tree"},
  16. {trunk="moretrees:jungletree_tree"},
  17. {trunk="moretrees:oak_tree"},
  18. {trunk="moretrees:palm_tree"},
  19. {trunk="moretrees:poplar_tree"},
  20. {trunk="moretrees:rubber_tree_tree"},
  21. {trunk="moretrees:sequoia_tree"},
  22. {trunk="moretrees:spruce_tree"},
  23. {trunk="moretrees:willow_tree"},
  24. }
  25. -- For all listed tree trunk nodes, register cuttings for them.
  26. for _, tree in ipairs(all_trees) do
  27. assert(type(tree.trunk) == "string")
  28. local ndef = minetest.registered_items[tree.trunk]
  29. assert(ndef)
  30. assert(ndef.sounds)
  31. assert(ndef.tiles)
  32. assert(ndef.description)
  33. local stairname = string.split(tree.trunk, ":")[2]
  34. assert(type(stairname) == "string")
  35. stairs.register_stair_and_slab(
  36. stairname,
  37. tree.trunk,
  38. {choppy = 3, oddly_breakable_by_hand = 1, flammable = 2},
  39. ndef.tiles,
  40. ndef.description,
  41. ndef.sounds
  42. )
  43. end
  44. -- Register a copy of this node for use with acacia trees sapling schematic.
  45. local acacia_branch = minetest.registered_nodes["stairs:slope_acacia_trunk_outer"]
  46. if acacia_branch then
  47. acacia_branch = table.copy(acacia_branch)
  48. acacia_branch.name = nil
  49. acacia_branch.drop = "default:stick 10"
  50. -- Acacia slopes left over from cut trees look pretty ugly.
  51. -- This fixes them up and makes them slightly useful.
  52. acacia_branch.on_finish_collapse = function(pos, node)
  53. minetest.remove_node(pos)
  54. minetest.add_item(pos, "default:stick " .. math.random(1, 10))
  55. end
  56. acacia_branch.on_collapse_to_entity = function(pos, node)
  57. minetest.add_item(pos, "default:stick " .. math.random(1, 10))
  58. end
  59. minetest.register_node(":basictrees:acacia_branch", acacia_branch)
  60. end