Guest User

test4

a guest
Apr 19th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 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.   if turtle.getItemCount(2) == 1 then
  49.     print("i have run out of blocks")
  50.     os.pullevent("turtle_inventory")
  51.     print("my inventory has changed, sure hope it was blocks")
  52.   end
  53.   if turtle.getFuelLevel() < 1 then
  54.     turtle.select(1)
  55.     turtle.refuel(1)
  56.     print("i have refueled")
  57.   end
  58.   line()
  59.   print("restarting while loop")
  60. end
Advertisement
Add Comment
Please, Sign In to add comment