soee

flog2

Jun 11th, 2013
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local offset = 0
  2.  
  3. local function fellTree()
  4.   turtle.dig()
  5.   turtle.forward()
  6.   local height = 0
  7.   while ( turtle.detectUp() ) do
  8.     turtle.dig()
  9.     turtle.digUp()
  10.     turtle.up()
  11.     height = height + 1
  12.   end
  13.  
  14.   turtle.turnRight()
  15.   turtle.dig()
  16.   turtle.forward()
  17.   turtle.turnLeft()
  18.  
  19.   for i=1,height do
  20.     turtle.dig()
  21.     turtle.digDown()
  22.     turtle.down()
  23.   end
  24.   turtle.dig()
  25.  
  26.   turtle.turnLeft()
  27.   turtle.forward()
  28.   turtle.turnLeft()
  29.   turtle.forward()
  30.   turtle.turnLeft()
  31.   turtle.turnLeft()
  32. end
  33.  
  34. local function plant()
  35.   turtle.up()
  36.   turtle.forward()
  37.   turtle.turnRight()
  38.   turtle.select(2)
  39.   for i=1,4 do
  40.     turtle.suckDown()
  41.     turtle.placeDown()
  42.     turtle.forward()
  43.     turtle.turnLeft()
  44.   end
  45.   turtle.turnRight()
  46.   turtle.forward()
  47.   turtle.turnRight()
  48.   turtle.turnRight()
  49.   turtle.down()
  50. end
  51.  
  52. local function moveToSuck()
  53.   turtle.turnLeft()
  54.   turtle.forward()
  55.   turtle.turnLeft()
  56.   turtle.forward()
  57.   turtle.forward()
  58.   turtle.turnLeft()
  59.   turtle.down()
  60. end
  61.  
  62. local function moveFromSuck()
  63.   turtle.turnLeft()
  64.   turtle.forward()
  65. end
  66.  
  67. local function suckWalk(dist)
  68.   for i=1,dist do
  69.     turtle.suck()
  70.     turtle.turnRight()
  71.     turtle.suck()
  72.     turtle.turnLeft()
  73.     turtle.turnLeft()
  74.     turtle.suck()
  75.     turtle.turnRight()
  76.     turtle.forward()
  77.   end
  78. end
  79.  
  80. local function suckRound()
  81.   for i=1,4 do
  82.     suckWalk(3)  
  83.     turtle.turnLeft()
  84.     suckWalk(2)
  85.   end
  86. end
  87.  
  88. local function findNextTree()
  89.   turtle.up()
  90.   turtle.select(1)
  91.   turtle.turnRight()
  92.   for i=1,10 do
  93.     if (turtle.forward()) then
  94.       offset = offset + 1
  95.     else
  96.       turtle.down()
  97.       return false
  98.     end
  99.     turtle.turnLeft()
  100.     if turtle.detect() then
  101.       turtle.down()
  102.       return true
  103.     else
  104.       turtle.turnRight()
  105.     end
  106.   end
  107.   turtle.down()
  108.   return false
  109. end
  110.  
  111. local function returnToStart()
  112.   turtle.turnLeft()
  113.   turtle.turnLeft()
  114.   while (offset > 0) do
  115.     turtle.forward()
  116.     offset = offset - 1
  117.     turtle.suckDown()
  118.   end
  119.   turtle.turnRight()
  120. end
  121.  
  122. local function unload()
  123.   for i=3,16 do
  124.     turtle.select(i)
  125.     turtle.dropDown()
  126.   end
  127. end
  128.  
  129. local function refuel()
  130.   turtle.select(1)
  131.   while ((turtle.getFuelLevel() < 200) and (turtle.getItemCount(1) > 1)) do
  132.     turtle.refuel(1)
  133.   end
  134. end
  135.  
  136. local function fellRow()
  137.   refuel()
  138.   while (findNextTree()) do
  139.     fellTree()
  140.     plant()
  141.   end
  142.   returnToStart()
  143.   unload()
  144. end
  145.  
  146. while (true) do
  147.   fellRow()
  148.   sleep(60)
  149. end
Advertisement
Add Comment
Please, Sign In to add comment