SHARE
TWEET

Untitled

a guest May 21st, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ---
  2. --- Created by deathsgun.
  3. --- DateTime: 2019-05-21 15:01
  4. ---
  5.  
  6. local length, height, width = ...
  7. local delay = 0.25
  8.  
  9. if length == nil or height == nil or width == nil then
  10.     print("Usage: miner <length> <height> <width>")
  11.     return false
  12. end
  13.  
  14. X = 0;
  15. Y = 0;
  16. Z = 0;
  17. ORIENTATION = 0;
  18.  
  19. function left()
  20.     turtle.turnLeft()
  21.     if ORIENTATION == 0 then
  22.         ORIENTATION = 3
  23.     else
  24.         ORIENTATION = ORIENTATION - 1
  25.     end
  26. end
  27.  
  28. function right()
  29.     turtle.turnRight()
  30.     if ORIENTATION == 3 then
  31.         ORIENTATION = 0
  32.     else
  33.         ORIENTATION = ORIENTATION + 1
  34.     end
  35. end
  36.  
  37. function up()
  38.     while not turtle.up() do
  39.         digUp()
  40.         sleep(delay)
  41.     end
  42.     Y = Y + 1
  43. end
  44.  
  45. function down()
  46.     while not turtle.down() do
  47.         digDown()
  48.         sleep(delay)
  49.     end
  50.     Y = Y - 1
  51. end
  52.  
  53. function forward()
  54.     while not turtle.forward() do
  55.         turtle.dig()
  56.         turtle.attack()
  57.         sleep(delay)
  58.     end
  59.     if ORIENTATION == 0 then
  60.         X = X + 1
  61.     elseif ORIENTATION == 1 then
  62.         Z = Z + 1
  63.     elseif ORIENTATION == 2 then
  64.         X = X - 1
  65.     elseif ORIENTATION == 3 then
  66.         Z = Z - 1
  67.     end
  68. end
  69.  
  70. function orient(arg1)
  71.     for _ =1, arg1 do
  72.         right()
  73.     end
  74. end
  75.  
  76. function dig()
  77.     while turtle.detect() do
  78.         turtle.dig()
  79.         sleep(delay)
  80.     end
  81. end
  82.  
  83. function digUp()
  84.     while turtle.detectUp() do
  85.         turtle.digUp()
  86.         sleep(delay)
  87.     end
  88. end
  89.  
  90. function digDown()
  91.     while turtle.detectDown() do
  92.         turtle.digDown()
  93.         sleep(delay)
  94.     end
  95. end
  96.  
  97. function go(lx,ly,lz)
  98.     print("going to "..lx.."/"..ly.."/"..lz)
  99.     if X < lx then
  100.         orient(0)
  101.         for _ =1,(lx-X) do
  102.             forward()
  103.         end
  104.     end
  105.  
  106.     if X > lx then
  107.         orient(2)
  108.         for _ =1,X-lx do
  109.             forward()
  110.         end
  111.     end
  112.  
  113.     if Y < ly then
  114.         for _ =1,ly-Y do
  115.             up()
  116.         end
  117.     end
  118.  
  119.     if Y > ly then
  120.         for _ =1,Y-ly do
  121.             down()
  122.         end
  123.     end
  124.  
  125.     if Z < lz then
  126.         orient(1)
  127.         for _ =1,lz-Z do
  128.             forward()
  129.         end
  130.     end
  131.  
  132.     if Z > lz then
  133.         orient(3)
  134.         for _ =1,Z-lz do
  135.             forward()
  136.         end
  137.     end
  138. end
  139.  
  140. function deposit()
  141.     for i=2,16 do
  142.         turtle.select(i)
  143.         while not turtle.drop() and turtle.getItemCount() ~= 0 do -- Waits until turtle can deposit item
  144.             sleep(1)
  145.         end
  146.         turtle.drop()
  147.     end
  148.     turtle.select(1)
  149.     return true
  150. end
  151.  
  152. function check()
  153.     if turtle.getItemCount(15) == 0 then
  154.         return false
  155.     else
  156.         return true
  157.     end
  158. end
  159.  
  160. print("Creating a tunnel "..height.." x "..width.." "..length.." long!")
  161.  
  162. lx = X
  163. ly = Y
  164. lz = Z
  165. for _ = 1, length do
  166.     forward()
  167.     lx = X
  168.     ly = Y
  169.     lz = Z
  170.     for _ = 1, width do
  171.         forward()
  172.         for _ = 1, height do
  173.             up()
  174.         end
  175.         go(X, ly, Z)
  176.         if _ == 1 then
  177.             right()
  178.         end
  179.     end
  180.     go(lx, ly, lz)
  181. end
  182.  
  183. go(0, 0, 0)
  184. orient(2)
  185. deposit()
  186. orient(0)
  187. print("Finished task!")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top