Advertisement
1lann

tree

Aug 1st, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. function toggleTurn(dir)
  2.     if dir == "right" then
  3.         turtle.turnRight()
  4.         turtle.dig()
  5.         turtle.forward()
  6.         turtle.turnRight()
  7.         return("left")
  8.     else
  9.         turtle.turnLeft()
  10.         turtle.dig()
  11.         turtle.forward()
  12.         turtle.turnLeft()
  13.         return("right")
  14.     end
  15. end
  16.  
  17.  
  18. while true do
  19.     n = 6
  20.     turtle.select(1)
  21.     print("Awaiting...")
  22.     turtle.place()
  23.     while turtle.compare() do
  24.         sleep(1)
  25.     end
  26.     print("Tree detected")
  27.     turtle.back()
  28.     turtle.turnLeft()
  29.     turtle.forward()
  30.     turtle.forward()
  31.     turtle.turnRight()
  32.     while true do
  33.         turtle.up()
  34.         n = n+1
  35.         if turtle.detectUp() then
  36.             break
  37.         elseif turtle.detect() then
  38.             break
  39.         end
  40.     end
  41.     if not turtle.detect() then
  42.         turtle.digUp()
  43.         turtle.up()
  44.     end
  45.     turn = "right"
  46.     for a =1, 2 do
  47.         for b =1, 5 do
  48.             for c =1, 4 do
  49.                 turtle.dig()
  50.                 turtle.forward()
  51.             end
  52.             if b < 5 then
  53.                 turn = toggleTurn(turn)
  54.             end
  55.         end
  56.         turtle.digUp()
  57.         turtle.up()
  58.         turtle.turnLeft()
  59.         turtle.turnLeft()
  60.     end
  61.     turtle.turnRight()
  62.     turtle.forward()
  63.     turtle.turnLeft()
  64.     turtle.dig()
  65.     turtle.forward()
  66.     for a = 1,2 do
  67.         turn = "right"
  68.         for b = 1,3 do
  69.             for c = 1,2 do
  70.                 turtle.dig()
  71.                 turtle.forward()
  72.             end
  73.             if b < 3 then
  74.                 turn = toggleTurn(turn)
  75.             end
  76.         end
  77.         turtle.digUp()
  78.         turtle.up()
  79.         turtle.turnLeft()
  80.         turtle.turnLeft()
  81.     end
  82.     turtle.turnRight()
  83.     turtle.forward()
  84.     turtle.turnLeft()
  85.     for i =1, n do
  86.         turtle.dig()
  87.         turtle.down()
  88.     end
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement