BioPrince

miner 3x1

Jun 14th, 2013
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. if #tArgs == 0 then
  4.   print("Usage: <blocks> [torches y/n]")
  5.   return
  6. end
  7.  
  8. turtle.dig()
  9.  
  10. if turtle.getFuelLevel() == 0 then
  11.   print("The turtle must have at least some fuel to start with.")
  12.   return
  13. elseif turtle.getFuelLevel() == "unlimited" then
  14.   print("This turtle does not use fuel to move")
  15.   return
  16. end
  17.  
  18. --Number of blocks to mine
  19. local maxDistance = tArgs[1]
  20. --do to place torches slot 1
  21. local torch = "n"
  22. if #tArgs >= 2 then
  23.   if turtle.getItemCount(1) < 1 then
  24.     print("No Torches")
  25.     return
  26.   end
  27.   torch = tArgs[2]
  28. end
  29. --local counter for how far the turtle has traveled
  30. local traveled = 0
  31. local tInt = 0
  32.  
  33. --main function of digging
  34. function miner() --  mining
  35.  
  36.   while turtle.dig() do
  37.     sleep(.2)
  38.   end
  39.   while turtle.digUp() do
  40.     sleep(.2)
  41.   end
  42.   while turtle.digDown() do
  43.     sleep(.2)
  44.   end
  45.   while turtle.dig() do
  46.     sleep(.2)
  47.   end
  48. end
  49.  
  50.  
  51. function pTorch()
  52.   if torch == "y" then
  53.     tInt = tInt + 1
  54.     if tInt >= 8 then
  55.       turtle.select(1)
  56.       turtle.placeDown()
  57.       tInt = 0
  58.     end
  59.     if turtle.getItemCount(1) < 1 then
  60.       torch = "n"
  61.     end
  62.   end
  63. end
  64.  
  65.     --Attempt to travel to max distance for mining
  66. for i = 1, maxDistance do
  67. miner()
  68. traveled = traveled + 1
  69. pTorch()
  70. turtle.forward()
  71. end
  72. print("Traveled "..traveled.." Blocks")
Advertisement
Add Comment
Please, Sign In to add comment