thatparadox

tunnelBottom

Apr 28th, 2017
102
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. startup = true
  2.  
  3. function saveDirection()
  4.   file = fs.open("direction","w")
  5.   file.write(direction)
  6.   file:close()
  7. end
  8.  
  9. if fs.exists("direction") == true then
  10.   file = fs.open("direction","r")
  11.   direction = file.readAll()
  12.   file:close()
  13. else
  14.   file = fs.open("direction","w")
  15.   file.write(0)
  16.   file:close()
  17.   direction = 0
  18. end
  19.  
  20. while tonumber(direction) ~= 0 do
  21.   if tonumber(direction) > 0 then
  22.     turtle.turnLeft()
  23.     direction = direction - 1
  24.   elseif tonumber(direction) < 0 then
  25.     turtle.turnRight()
  26.     direction = direction + 1
  27.   end
  28.   file = fs.open("direction","w")
  29.   file.write(direction)
  30.   file:close()
  31. end
  32.  
  33. while true do
  34.   if startup == false then
  35.     partner = false
  36.     while partner == false do
  37.       a,b = turtle.inspectUp()
  38.       if b == "No block to inspect" then
  39.         b = {"no","block"}
  40.       end
  41.       for k,v in pairs(b) do
  42.         if v == "computercraft:CC-Turtle" then
  43.           partner = true
  44.         end
  45.       end
  46.     sleep(.05)
  47.     end
  48.     startup = false
  49.   elseif startup == true then
  50.    startup = false
  51.    sleep(.5)
  52.   end
  53.   sleep(.5)
  54.   turtle.dig()
  55.   turtle.forward()
  56.   turtle.turnRight()
  57.   direction = direction +1
  58.   saveDirection()
  59.   while turtle.getItemCount( turtle.getSelectedSlot() ) == 0 do
  60.     if turtle.getSelectedSlot() == 9 then
  61.       turtle.select(1)
  62.     else
  63.       turtle.select(turtle.getSelectedSlot() +1)
  64.     end  
  65.   end
  66.   turtle.place()
  67.   turtle.turnLeft()
  68.   direction = direction -1
  69.   saveDirection()
  70.   turtle.turnLeft()
  71.   direction = direction -1
  72.   saveDirection()
  73.   while turtle.getItemCount( turtle.getSelectedSlot() ) == 0 do
  74.     if turtle.getSelectedSlot() == 9 then
  75.       turtle.select(1)
  76.     else
  77.       turtle.select(turtle.getSelectedSlot() +1)
  78.     end  
  79.   end
  80.   turtle.place()
  81.   turtle.turnRight()
  82.   direction = direction +1
  83.   saveDirection()
  84.   while turtle.getItemCount( turtle.getSelectedSlot() ) == 0 do
  85.     if turtle.getSelectedSlot() == 9 then
  86.       turtle.select(1)
  87.     else
  88.       turtle.select(turtle.getSelectedSlot() +1)
  89.     end  
  90.   end
  91.   turtle.placeDown()
  92. end
RAW Paste Data