Advertisement
Fatherless

fellGiant

Dec 6th, 2024 (edited)
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. --[[
  2.  
  3.     This program tells a turtle to cut down a giant spruce tree
  4.  
  5. ]]
  6.  
  7. --[[ Functions ]]
  8. local function fellColumn()
  9.     turtle.dig()
  10.     turtle.forward()
  11.     while turtle.detectUp() do
  12.         turtle.digUp()
  13.         turtle.up()
  14.     end
  15.     while not turtle.detectDown() do
  16.         turtle.down()
  17.     end
  18. end
  19.  
  20. local function fwd()
  21.     while not turtle.forward() do
  22.         turtle.dig()
  23.     end
  24. end
  25.  
  26.  
  27. --[[ Main ]]
  28.  
  29. -- Determine that the tree is grown
  30. local has_block, data = turtle.inspect()
  31. if data.name ~= "minecraft:spruce_log" then
  32.     print("There's no grown tree in front of me")
  33.     return
  34. end
  35.  
  36. -- Determine if you have enough fuel
  37. if turtle.getFuelLevel() < 242 then
  38.     print("Please provide at least 242 fuel")
  39.     return
  40. end
  41.  
  42. -- Collect all logs
  43. fellColumn()
  44. fellColumn()
  45. turtle.turnRight()
  46. fellColumn()
  47. turtle.turnRight()
  48. fellColumn()
  49.  
  50. -- Drop off logs
  51. fwd()
  52. for i = 1, 16 do
  53.     turtle.select(i)
  54.     turtle.dropDown()
  55. end
  56.  
  57. -- Get saplings
  58. turtle.turnRight()
  59. fwd()
  60. turtle.turnRight()
  61. turtle.select(1)
  62. turtle.suckDown(4)
  63.  
  64. -- Plant saplings
  65. turtle.forward()
  66. turtle.forward()
  67. turtle.turnRight()
  68. turtle.forward()
  69. turtle.turnRight()
  70. turtle.place() -- Sapling 1
  71. turtle.turnLeft()
  72. turtle.back()
  73. turtle.place()-- Sapling 2
  74. turtle.turnLeft()
  75. turtle.back()
  76. turtle.place() -- Sapling 3
  77. turtle.back()
  78. turtle.place() -- Sapling 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement