Advertisement
jcoutie

Single Shaft Miner

Jan 23rd, 2014
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. -- variables
  2. height = 0
  3. distFront = 0
  4. distRight = 0
  5. curDepth = 0
  6.  
  7. -- Functions
  8.  
  9. local function tMove(distance)
  10.   for i=1,distance do
  11.     while turtle.forward() == false do
  12.       turtle.dig()
  13.       turtle.attack()
  14.       sleep(0.5)
  15.     end
  16.   end
  17. end
  18.  
  19. local function tDescend(distance)
  20.   for i=1,distance do
  21.     while turtle.down() == false do
  22.       turtle.digDown()
  23.       turtle.attackDown()
  24.       sleep(0.5)
  25.     end
  26.   end
  27. end
  28.  
  29. local function tAscend(distance)
  30.   for i=1,distance do
  31.     while turtle.up() == false do
  32.       turtle.digUp()
  33.       turtle.attackUp()
  34.       sleep(0.5)
  35.     end
  36.   end
  37. end
  38.  
  39. local function turnaround()
  40.   turtle.turnRight()
  41.   turtle.turnRight()
  42. end
  43.  
  44. local function checkInv()
  45. if turtle.getItemCount(16) > 0 do
  46.   tAscend(curDepth)
  47.   turtle.turnLeft()
  48.   tMove(distRight)
  49.   turtle.turnLeft()
  50.   tMove(distFront)
  51.   for i=1,16 do
  52.     turtle.select(i)
  53.     turtle.drop()
  54.   end
  55. turtle.set(1)
  56.   turnaround()
  57.   tMove(distFront)
  58.   turtle.turnRight()
  59.   tMove(distRight)
  60.   turtle.turnLeft()
  61.   tDescend(curDepth)
  62. end
  63. end
  64.  
  65. -- Startup
  66.  
  67. term.clear()
  68. term.setCursorPos(1,1)
  69. print("Ready to mine shafts!")
  70. print()
  71. print()
  72. print("Choose forward offset:")
  73. distFront = read(input)
  74. print("Choose right offset:")
  75. distRight = read(input)
  76. print("Choose depth:")
  77. depth = read(input)
  78.  
  79. --Main Loop
  80. tMove(distFront)
  81. turtle.turnRight()
  82. tMove(distRight)
  83. turtle.turnLeft()
  84. for i=0,depth do
  85.   checkInv()
  86.   tDescend(1)
  87.   curDepth = curDepth + 1
  88. end
  89. tAscend(depth)
  90. turtle.turnLeft()
  91. tMove(distRight)
  92. turtle.turnLeft()
  93. tMove(distFront)
  94. for i=1,16 do
  95.   turtle.set(i)
  96.   turtle.drop()
  97. end
  98. turtle.select(1)
  99. turnaround()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement