Advertisement
Guest User

test

a guest
Apr 19th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local finished = false
  2. local wall = 0
  3.  
  4. function line()
  5.   turtle.select(2)
  6.   if not turtle.detectDown() then
  7.    turtle.placeDown()
  8.    print("block placed")
  9.   end
  10.   if not turtle.detect() then
  11.    turtle.forward()
  12.    print("moving forward")
  13.    else
  14.      turtle.select(3)
  15.      if turtle.compare() then
  16.       finished = true
  17.       print("i am finished")
  18.       else
  19.         print("i have reached a wall")
  20.         if wall == 0 then
  21.           turtle.turnRight()
  22.           turtle.forward()
  23.           turtle.turnLeft()
  24.           while not turtle.detect() do
  25.             turtle.forward()
  26.           end
  27.           print("i have reached the second wall")
  28.           wall = 1
  29.           turtle.turnRight()
  30.           turtle.turnRight()
  31.           elseif wall == 1 then            
  32.             turtle.turnLeft()
  33.             turtle.forward()
  34.             turtle.turnRight()
  35.             while not turtle.detect() do
  36.               turtle.forward()
  37.             end
  38.             print("i have reached the third wall")
  39.             wall = 0
  40.             turtle.turnLeft()
  41.             turtle.turnLeft()
  42.         end
  43.      end
  44.   end
  45. end
  46.  
  47. while finished == false do
  48.   line()
  49.   print("restarting while loop")
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement