Advertisement
Guest User

mine

a guest
Dec 17th, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. local blocksMined = 0
  2. local col = 0
  3. local args = {...}
  4. local colsToMine = args[1]
  5. local length = args[2]
  6.  
  7. function checkFuel()
  8.   turtle.select(16)
  9.   if turtle.getItemCount(16) == 0 then
  10.     print("Add coal to slot 16!")
  11.     sleep(2)
  12.   else
  13.     turtle.refuel(1)
  14.   end
  15. end
  16.  
  17. function dig()
  18.   while turtle.detect() do
  19.     turtle.dig()
  20.   end
  21.   blocksMined = blocksMined + 1  
  22. end
  23.  
  24. function forward()
  25.   while not turtle.forward() do
  26.     checkFuel()
  27.     dig()
  28.   end
  29.   checkFuel()
  30. end
  31.  
  32. function turn()
  33.   if col%2 > 0 then
  34.     left()
  35.     col = col + 1
  36.   else
  37.     right()
  38.     col = col + 1
  39.   end
  40. end
  41.  
  42. function left()
  43.   turtle.turnLeft()
  44.   dig()
  45.   forward()
  46.   turtle.turnLeft()
  47. end
  48.  
  49. function right()
  50.   turtle.turnRight()
  51.   dig()
  52.   forward()
  53.   turtle.turnRight()
  54. end
  55.  
  56. function mineCol()
  57.   for i=0, length do
  58.     dig()
  59.     forward()
  60.   end
  61.   turn()
  62. end
  63.  
  64. for i=1, colsToMine do
  65.   print("Mining column "..i)
  66.   mineCol()
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement