Guest User

flog2

a guest
Jun 11th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.81 KB | None | 0 0
  1.  
  2. local offset = 0
  3.  
  4. local function fellTree()
  5.   turtle.dig()
  6.   turtle.forward()
  7.   local height = 0
  8.   while ( turtle.detectUp() ) do
  9.     turtle.dig()
  10.     turtle.digUp()
  11.     turtle.up()
  12.     height = height + 1
  13.   end
  14.  
  15.   turtle.turnRight()
  16.   turtle.dig()
  17.   turtle.forward()
  18.   turtle.turnLeft()
  19.  
  20.   for i=1,height do
  21.     turtle.dig()
  22.     turtle.digDown()
  23.     turtle.down()
  24.   end
  25.   turtle.dig()
  26. end
  27.  
  28. local function plant()
  29.   turtle.up()
  30.   turtle.select(2)
  31.   for i=1,4 do
  32.     turtle.suckDown()
  33.     turtle.placeDown()
  34.     turtle.forward()
  35.     turtle.turnLeft()
  36.   end
  37. end
  38.  
  39. local function moveToSuck()
  40.   turtle.turnLeft()
  41.   turtle.forward()
  42.   turtle.turnLeft()
  43.   turtle.forward()
  44.   turtle.forward()
  45.   turtle.turnLeft()
  46.   turtle.down()
  47. end
  48.  
  49. local function moveFromSuck()
  50.   turtle.turnLeft()
  51.   turtle.forward()
  52. end
  53.  
  54. local function suckWalk(dist)
  55.   for i=1,dist do
  56.     turtle.suck()
  57.     turtle.turnRight()
  58.     turtle.suck()
  59.     turtle.turnLeft()
  60.     turtle.turnLeft()
  61.     turtle.suck()
  62.     turtle.turnRight()
  63.     turtle.forward()
  64.   end
  65. end
  66.  
  67. local function suckRound()
  68.   for i=1,4 do
  69.     suckWalk(3)  
  70.     turtle.turnLeft()
  71.     suckWalk(2)
  72.   end
  73. end
  74.  
  75. local function findNextTree()
  76.   turtle.up()
  77.   turtle.select(1)
  78.   turtle.turnRight()
  79.   for i=1,10 do
  80.     turtle.forward()
  81.     offset = offset + 1
  82.     turtle.turnLeft()
  83.     if turtle.detect() then
  84.       turtle.down()
  85.       return true
  86.     else
  87.       turtle.turnRight()
  88.     end
  89.   end
  90.   turtle.down()
  91.   return false
  92. end
  93.  
  94. local function returnToStart()
  95.   turtle.turnLeft()
  96.   turtle.turnLeft()
  97.   while (offset > 0) do
  98.     turtle.forward()
  99.     offset = offset - 1
  100.   end
  101.   turtle.turnRight()
  102. end
  103.  
  104. while (findNextTree()) do
  105.   fellTree()
  106.   plant()
  107.   moveToSuck()
  108.   suckRound()
  109.   moveFromSuck()
  110. end
  111. returnToStart()
Advertisement
Add Comment
Please, Sign In to add comment