Advertisement
SythsGod

Felling (2x2)

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