Guest User

Chopper_nobm

a guest
Jun 30th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. local function checkFuel()
  2.   if turtle.getFuelLevel() < 1 then
  3.     turtle.select(2)
  4.     turtle.refuel(1)
  5.   end
  6. end
  7. --
  8. local function Saplings()
  9.   Saplings = tonumber(turtle.getItemCount(1))
  10.   if Saplings > 3 then
  11.     sleep(0)
  12.   else
  13.     print "Need at least 4 saplings in Slot 1"
  14.       while Saplings < 4 do
  15.         Saplings = tonumber(turtle.getItemCount(1))
  16.         sleep(0)
  17.       end
  18.   end
  19. end
  20. --
  21. local function Start()
  22.   turtle.dig()
  23.   checkFuel()
  24.   turtle.forward()
  25. end
  26. --
  27. local function FellUp()
  28. up = 0
  29.   while turtle.detectUp() do
  30.     turtle.digUp()
  31.     turtle.dig()
  32.     checkFuel()
  33.     turtle.up()
  34.     up = up + 1
  35.   end
  36. end
  37. --
  38. local function Move()
  39.   turtle.dig()
  40.   checkFuel()
  41.   turtle.turnRight()
  42.   turtle.dig()
  43.   turtle.forward()
  44.   turtle.turnLeft()
  45. end
  46. --
  47. local function FellDown()
  48.   while up > 0 do
  49.     turtle.dig()
  50.     turtle.digDown()
  51.     checkFuel()
  52.     turtle.down()
  53.     up = up - 1
  54.   end
  55. end
  56. --
  57. local function Plant() --That's a mess. Sorry :)
  58.   turtle.dig()
  59.   checkFuel()
  60.   turtle.up()
  61.   turtle.select(1)
  62.   turtle.placeDown()
  63.   checkFuel()
  64.   turtle.forward()
  65.   turtle.select(1)
  66.   turtle.placeDown()
  67.   turtle.turnLeft()
  68.   checkFuel()
  69.   turtle.forward()
  70.   turtle.select(1)
  71.   turtle.placeDown()
  72.   turtle.turnLeft()
  73.   checkFuel()
  74.   turtle.forward()
  75.   turtle.select(1)
  76.   turtle.placeDown()
  77.   checkFuel()
  78.   turtle.forward()
  79.   checkFuel()
  80.   turtle.turnRight()
  81.   turtle.down()
  82. end
  83. --
  84. local function Drop()
  85.     for i = 2,16 do
  86.         turtle.select(i)
  87.         turtle.drop()
  88.     end
  89. end
  90. -- Begin
  91. local function CheckTree()
  92.   turtle.select(1)
  93.   if turtle.compare() then
  94.     Check = 0
  95.   else
  96.     Check = 1
  97.   end
  98. end
  99. --
  100. local function Chop() -- Main function
  101.   while Check == 1 do
  102.     term.clear() term.setCursorPos(1,1) term.write("Tree detected...Chopping")
  103.     Saplings()
  104.     Start()
  105.     FellUp()
  106.     Move()
  107.     FellDown()
  108.     Plant()
  109.     Drop()
  110.     turtle.turnRight()
  111.     Check = 0
  112.   end
  113. end
  114. --
  115. while true do
  116.   CheckTree()
  117.   Chop()
  118.   sleep(1)
  119.   if Check == 0 then
  120.     term.clear()
  121.     term.setCursorPos(1,1)
  122.     term.write("Waiting for Tree")
  123.   end
  124. end
Advertisement
Add Comment
Please, Sign In to add comment