Jharii

chopTree

Jan 21st, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. function fuelUp()
  2.   if turtle.getFuelLevel() == 0 then
  3.     turtle.select(1)
  4.     turtle.refuel(1)
  5.     print("Refueling...")
  6.     print("Current fuel level: " .. turtle.getFuelLevel())
  7.   end
  8.  
  9.   if turtle.getFuelLevel() == 0 then
  10.     print("No fuel in slot 1.")
  11.     chopping = false
  12.    end
  13. end
  14.  
  15. active = true
  16. chopping = true
  17. counter = 0
  18.  
  19. turtle.dig()
  20. fuelUp()
  21. turtle.forward()
  22.  
  23. while active do
  24.   fuelUp()  
  25.  
  26.   if turtle.detectUp() then
  27.     turtle.digUp()
  28.     turtle.up()
  29.     counter = counter + 1
  30.   else
  31.     chopping = false
  32.     print("Done chopping.")
  33.   end
  34.  
  35.   if chopping == false then
  36.     while turtle.detectDown() == false do
  37.       fuelUp()
  38.       turtle.down()
  39.     end
  40.     active = false
  41.     print("")
  42.     print("Job's done.")
  43.     print("Chopped " .. counter .. " items.")
  44.     print("Fuel remaining: " .. turtle.getFuelLevel())
  45.   end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment