Advertisement
Ignius12

tunnler

Jan 23rd, 2020 (edited)
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. function checkForGravel()
  2.     local block = turtle.detect(front)
  3.     if(block == true) then
  4.         while(turtle.detect(front) == true) do
  5.             turtle.dig()
  6.         end
  7.     end
  8. end
  9. function tunnel()
  10.     turtle.dig()
  11.     checkForGravel()
  12.     turtle.forward()
  13.     turtle.turnLeft()
  14.     turtle.dig()
  15.     checkForGravel()
  16.     turtle.forward()
  17.     turtle.digUp()
  18.     turtle.up()
  19.     turtle.digUp()
  20.     turtle.up()
  21.     turtle.turnRight()
  22.     turtle.turnRight()
  23.     turtle.dig()
  24.     checkForGravel()
  25.     turtle.forward()
  26.     turtle.dig()
  27.     checkForGravel()
  28.     turtle.forward()
  29.     turtle.digDown()
  30.     turtle.down()
  31.     turtle.turnLeft()
  32.     turtle.turnLeft()
  33.     turtle.dig()
  34.     turtle.digDown()
  35.     turtle.down()
  36.     turtle.forward()
  37.     turtle.turnRight()
  38. end
  39.  
  40. local count = 0
  41. local back_count = 0
  42. local torch = 0
  43. rednet.open("left")
  44. local sender, message, protocol = rednet.receive("miner")
  45. print(message)
  46. local start = true
  47. while(start) do
  48.     if  message == "start" then
  49.         start = false
  50.     end
  51. end
  52. while(turtle.getItemCount(1) > 0) do
  53.     while(turtle.getItemCount(16) <= 0) do
  54.         print("I have traveled " .. count + 1 .. " blocks")
  55.         tunnel()
  56.             if (torch == 6) then
  57.                 turtle.turnLeft()
  58.                 turtle.turnLeft()
  59.                 turtle.select(1)
  60.                 turtle.place()
  61.                 turtle.turnLeft()
  62.                 turtle.turnLeft()
  63.                 torch = 0
  64.                 print("Placing a torch")
  65.             end
  66.         count = count + 1
  67.         torch = torch + 1
  68.         print("I have dug out " .. count * 9 .. " blocks")
  69.         if(turtle.getFuelLevel() == 0) then
  70.             print("Refueling!")
  71.             turtle.refuel()
  72.             print("Fuel level at " .. turtle.getFuelLevel())
  73.         end
  74.     end
  75.     turtle.turnRight()
  76.     turtle.turnRight()
  77.     print("Time to go back " .. count .. " blocks")
  78.     turtle.up()
  79.     back_count = count
  80.     while(count > 0) do
  81.         turtle.forward()
  82.         count = count - 1
  83.     end
  84.     turtle.down()
  85.     for i=16,3,-1 do
  86.         turtle.select(i)
  87.         turtle.drop()
  88.     end
  89.     turtle.turnRight()
  90.     turtle.turnRight()
  91.     turtle.up()
  92.     while(back_count > 0) do
  93.         turtle.forward()
  94.         back_count = back_count - 1
  95.     end
  96.     turtle.down()
  97. end
  98. print("All done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement