LayZee

Turtle Fir Wood Chopper

May 9th, 2013
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. local sapling = 15
  2. local bonemeal = 16
  3.  
  4. function bone ()
  5.   if turtle.getItemCount(bonemeal) > 1 then
  6.     turtle.select(bonemeal)
  7.     turtle.place()
  8.   end
  9. end
  10.  
  11. function plant ()
  12.   if turtle.getItemCount(sapling) < 5 then
  13.     turtle.turnLeft()
  14.     turtle.select(sapling)
  15.     turtle.drop()
  16.     turtle.suck()
  17.    
  18.     while turtle.getItemCount(sapling) < 5 do
  19.       print("Waiting for more saplings")
  20.       sleep(60)
  21.       turtle.drop()
  22.       turtle.suck()
  23.     end
  24.  
  25.     turtle.turnRight()
  26.   end
  27.  
  28.   turtle.select(sapling)
  29.   sleep(1)
  30.   turtle.forward()
  31.   turtle.forward()
  32.   turtle.turnLeft()
  33.   turtle.place()
  34.   turtle.turnRight()
  35.   turtle.back()
  36.   turtle.place()
  37.   turtle.turnLeft()
  38.   turtle.place()
  39.   turtle.turnRight()
  40.   turtle.back()
  41.   turtle.place()
  42. end
  43.  
  44. function detect ()
  45.   turtle.select(sapling)
  46.  
  47.   while turtle.compare() do
  48.     bone()
  49.     sleep(1)
  50.     turtle.select(sapling)
  51.   end
  52. end
  53.  
  54. function chop ()
  55.   local height = 1
  56.   local downSteps = 1
  57.  
  58.   turtle.select(1)
  59.   turtle.dig()
  60.   turtle.forward()
  61.  
  62.   while turtle.detectUp() do
  63.     turtle.dig()
  64.     turtle.digUp()
  65.     turtle.up()
  66.    
  67.     height = height + 1
  68.   end
  69.  
  70.   turtle.dig()
  71.   turtle.turnLeft()
  72.   turtle.dig()
  73.   turtle.forward()
  74.   turtle.turnRight()
  75.  
  76.   while downSteps < height do
  77.     turtle.dig()
  78.     turtle.digDown()
  79.     turtle.down()
  80.    
  81.     downSteps = downSteps + 1
  82.   end
  83.  
  84.   turtle.dig()
  85.   turtle.turnLeft()
  86.   turtle.back()
  87.   turtle.turnRight()
  88.   turtle.back()
  89. end
  90.  
  91. function empty ()
  92.   for slot = 1, 14 do
  93.     if turtle.getItemCount(slot) > 0 then
  94.       turtle.select(slot)
  95.       turtle.dropUp()
  96.     end
  97.   end
  98. end
  99.  
  100. while true do
  101.   plant()
  102.   bone()
  103.   detect()
  104.   chop()
  105.   empty()
  106. end
Advertisement
Add Comment
Please, Sign In to add comment