Advertisement
SythsGod

Felling (1x1)

Jul 5th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. local isBlock = true
  2. local totalBlocks = 0
  3. local onGround = true
  4.  
  5. function fuelCheck()
  6.     fuelLevel = turtle.getFuelLevel()
  7.     print("Checking fuel before start...")
  8.     os.sleep(0.5)
  9.     if fuelLevel < 100 then
  10.         os.error("Insufficient fuel in tank.")
  11.     else
  12.         print("Sufficient fuel in tank.")
  13.     end
  14. end
  15.  
  16. function init()
  17.     fuelCheck()
  18.  
  19.     turtle.dig()
  20.     turtle.forward()
  21. end
  22.  
  23. function fellTree()
  24.     onGround = true
  25.     isBlock = true
  26.  
  27.     while isBlock or totalBlocks < 5 do
  28.         totalBlocks = totalBlocks + 1
  29.         isBlock = turtle.detectUp()
  30.         turtle.digUp()
  31.         turtle.up()
  32.     end
  33.  
  34.     if not isBlock then
  35.         repeat
  36.             turtle.down()
  37.             onGround = turtle.detectDown()
  38.         until onGround
  39.     end
  40. end
  41.  
  42. init()
  43. fellTree()
  44.  
  45. print("Total blocks felled/moved: " .. totalBlocks)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement