Advertisement
Guest User

tunnel.lua

a guest
Jan 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. print("How Far would you like to go?")
  2. local length = tonumber(read())
  3. term.clear()
  4. print("dig 3 block high?")
  5. print("Type yes or no")
  6. local answer = read()
  7. local height = 2
  8. if answer == "yes" then
  9.     height = 3
  10. end
  11. term.clear()
  12. local distance = 0
  13.  
  14. function empty()
  15.     turtle.turnLeft()
  16.     turtle.turnLeft()
  17.     for i = 1,distance do
  18.         turtle.forward()
  19.     end
  20.     for i = 2,16 do
  21.         turtle.select(i)
  22.         turtle.drop()
  23.     end
  24.     turtle.turnLeft()
  25.     turtle.turnLeft()
  26.     for i = 1,distance do
  27.         turtle.forward()
  28.     end
  29. end
  30. function mine()
  31.     while distance < length do
  32.         turtle.dig()
  33.         turtle.forward()
  34.         if height == 3 then
  35.             turtle.digDown()
  36.         end
  37.         turtle.digUp()
  38.         distance = distance +1
  39.         check()
  40.     end
  41. end
  42. function check()
  43.     turtle.select(1)
  44.     local number = turtle.getItemCount() -1
  45.     if number > 0 then
  46.         turtle.dropDown(number)
  47.     end
  48.     turtle.select(16)
  49.     if turtle.getItemCount() >=1 then
  50.         empty()
  51.     end
  52.     turtle.select(1)
  53. end
  54.  
  55. mine()
  56. function done()
  57.     turtle.turnLeft()
  58.     turtle.turnLeft()
  59.     for i = 1,distance do
  60.         turtle.forward()
  61.     end
  62.     if turtle.detect() then
  63.         for i = 1,16 do
  64.             turtle.select(i)
  65.             turtle.drop()
  66.         end
  67.     end
  68.     turtle.turnLeft()
  69.     turtle.turnLeft()
  70. end
  71. done()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement