SythsGod

Untitled

Jul 5th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 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. function moveNext()
  43.     turtle.dig()
  44.     turtle.forward()
  45.     turtle.turnRight()
  46. end
  47.  
  48. for i = 0, 3, 1 do
  49.     init()
  50.     fellTree()
  51.     moveNext()
  52. end
  53.  
  54. print("Total blocks felled/moved: " .. totalBlocks)
Add Comment
Please, Sign In to add comment