Hashtagaming

minev2

Jan 7th, 2013
2,851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 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. --Mines out one block above and in front, then moves forward
  25. local function digForward()
  26.   turtle.dig()
  27.   turtle.digUp()
  28.   turtle.forward()
  29. end
  30.  
  31. --Digs out the area to move to the next tunnel (requires args[1])
  32. local function digOut(direct)
  33.   digForward()
  34.   if direct == "left" then
  35.     turtle.turnRight()
  36.     turtle.dig()
  37.     turtle.forward()
  38.     turtle.digUp()
  39.     turtle.back()
  40.     turtle.turnLeft()
  41.   end
  42.   if direct == "right" then
  43.     turtle.turnLeft()
  44.     turtle.dig()
  45.     turtle.forward()
  46.     turtle.digUp()
  47.     turtle.back()
  48.     turtle.Right()
  49.   end
  50.   digForward()
  51. end
  52.  
  53. --Digs a tunnel given distance args[0] (requires args[0])
  54. local function tunnel()
  55. for i=1,dist,1 do
  56.   mineTunnel()
  57. end
  58.  
  59. if direct == "left" then
  60.   turtle.turnLeft()
  61.   mineTunnel()
  62.   turtle.turnLeft()
  63. end
  64. if direct == "right" then
  65.   turtle.turnRight()
  66.   mineTunnel()
  67.   turtle.turnRight()
  68. end
  69.  
  70. for i=1,dist,1 do
  71.   mineTunnel()
  72. end
  73. end
  74.  
  75. --Executes until told to stop (future change will go until no more chests available)
  76. while true do
  77. tunnel()
  78. turtle.select(1)
  79. turtle.dig()
  80. turtle.place()
  81. for slot=2,16,1 do
  82.   turtle.select(slot)
  83.   while turtle.getItemCount(slot) > 0 do
  84.     turtle.drop()
  85.   end
  86. end
  87.  
  88. if direct == "left" then
  89.   turtle.turnRight()
  90. end
  91. if direct == "right" then
  92.   turtle.turnLeft()
  93. end
  94.  
  95. turtle.dig()
  96. turtle.forward()
  97. digForward()
  98. digForward()
  99. turtle.digUp()
  100.  
  101. if direct == "left" then
  102.   turtle.turnRight()
  103. end
  104. if direct == "right" then
  105.   turtle.turnLeft()
  106. end
  107. end
Advertisement
Add Comment
Please, Sign In to add comment