Hashtagaming

mine

Dec 28th, 2012
3,360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. --Retrieve variables/Instantiate Values
  2. local args = {...}
  3.  
  4. --First argument = how long tunnel is
  5. local dist = tonumber(args[1])
  6.  
  7. --Second argument = What direction the tunnels go
  8. local direct = tostring(args[2])
  9.  
  10. --Mines out blocks in front and above (for Gravel or Sand) [Moves forward when clear]
  11. local function mineTunnel()
  12.   if turtle.detect() then
  13.     turtle.dig()
  14.   end
  15.   if turtle.detectUp() then
  16.     turtle.digUp()
  17.   end
  18.   while not turtle.forward() do
  19.     turtle.dig()
  20.     turtle.digUp()
  21.   end
  22. end
  23.  
  24. --Digs a tunnel given distance args[0] (requires args[0])
  25. local function tunnel()
  26. for i=1,dist,1 do
  27.   mineTunnel()
  28. end
  29.  
  30. if direct == "left" then
  31.   turtle.turnLeft()
  32.   mineTunnel()
  33.   turtle.turnLeft()
  34. end
  35. if direct == "right" then
  36.   turtle.turnRight()
  37.   mineTunnel()
  38.   turtle.turnRight()
  39. end
  40.  
  41. for i=1,dist,1 do
  42.   mineTunnel()
  43. end
  44. end
  45.  
  46. --Executes until told to stop
  47. while true do
  48. tunnel()
  49. turtle.select(1)
  50. turtle.dig()
  51. turtle.place()
  52. for slot=2,16,1 do
  53.   turtle.select(slot)
  54.   while turtle.getItemCount(slot) > 0 do
  55.     turtle.drop()
  56.   end
  57. end
  58.  
  59. if direct == "left" then
  60.   turtle.turnRight()
  61. end
  62. if direct == "right" then
  63.   turtle.turnLeft()
  64. end
  65.  
  66. turtle.dig()
  67. turtle.forward()
  68. turtle.digUp()
  69. turtle.dig()
  70. turtle.forward()
  71. turtle.digUp()
  72. turtle.dig()
  73. turtle.forward()
  74. turtle.digUp()
  75.  
  76. if direct == "left" then
  77.   turtle.turnRight()
  78. end
  79. if direct == "right" then
  80.   turtle.turnLeft()
  81. end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment