Advertisement
FakoTheGreat

Simple Lumberjack Turtle

May 6th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local saplingSlot = 13
  2. local bonemealSlot = 14
  3. local fuelSlot = 15
  4. local logSlot = 16
  5. local issue = false
  6.  
  7. function checkFuel ()
  8.   if turtle.getFuelLevel() < 6 then
  9.     if turtle.getItemCount(fuelSlot) > 1 then
  10.       turtle.select(fuelSlot)
  11.       while turtle.getFuelLevel() < 6 do
  12.         turtle.refuel(1)
  13.       end
  14.     else
  15.       print("Fuel Reserves too low. Exiting.")
  16.       issue = true
  17.     end
  18.   end
  19. end
  20.  
  21. function backDown ()
  22.   checkFuel()
  23.   while turtle.down() do
  24.     checkFuel()
  25.   end
  26. end
  27.  
  28. function chopTree ()
  29.   checkFuel()
  30.   turtle.select(logSlot)
  31.   while turtle.compare() do
  32.     checkFuel()
  33.     turtle.dig()
  34.     while not turtle.up() do
  35.       turtle.digUp()
  36.     end
  37.     turtle.select(logSlot)
  38.   end
  39.   backDown()
  40.   if turtle.getItemCount(saplingSlot) > 1 then
  41.     turtle.select(saplingSlot)
  42.     turtle.place()
  43.   else
  44.     print("Low on saplings. Exiting.")
  45.     issues = true
  46.   end
  47. end
  48.  
  49. backDown()
  50.  
  51. turtle.select(logSlot)
  52. if not turtle.compare() then
  53.   turtle.dig()
  54.   turtle.select(saplingSlot)
  55.   turtle.place()
  56. end
  57.  
  58. while not issues do
  59.   turtle.select(logSlot)
  60.   if not turtle.compare() then
  61.     if turtle.getItemCount(bonemealSlot) > 1 then
  62.       turtle.select(bonemealSlot)
  63.       turtle.place()
  64.     end
  65.   else
  66.     chopTree()
  67.   end
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement