Advertisement
Inksaver

fellTree from Youtube tutorial

Apr 5th, 2020
661
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- code featured in https://www.youtube.com/watch?v=EWN_mphyw9o
  2.  
  3. function getSaplings()
  4.     -- return true/false if saplings are dug
  5.     for index = 1, 4 do
  6.         turtle.dig()
  7.         turtle.turnRight()
  8.     end
  9. end
  10.  
  11. function plantSapling()
  12.     -- if sapling present plant it
  13.     if turtle.getItemCount(2) > 0 then
  14.         turtle.up()
  15.         turtle.select(2)
  16.         if turtle.placeDown() then
  17.             print("Sapling placed")
  18.             turtle.back()
  19.             turtle.down()
  20.         else
  21.             print("If you are hungry, I have an apple")
  22.         end
  23.     end
  24. end
  25.  
  26. function main()
  27.     -- clear screen
  28.     term.clear()
  29.     term.setCursorPos(1,1)
  30.     print("Press Esc key. Starting in 2 secs")
  31.     os.sleep(2)
  32.     -- select slot 1
  33.     turtle.select(1)
  34.     turtle.dig()
  35.     turtle.craft()
  36.     turtle.refuel()
  37.     turtle.forward()
  38.     --move up and cut the tree
  39.     while turtle.detectUp() == true do
  40.         turtle.digUp()
  41.         turtle.up()
  42.         getSaplings()
  43.     end
  44.     -- reached tree top
  45.     while turtle.detectDown() == false do
  46.         turtle.down()
  47.     end
  48.     plantSapling() 
  49. end
  50.  
  51. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement