Z4i

Mine 4

Z4i
Dec 25th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.14 KB | None | 0 0
  1. local length, depth = ...
  2. local modem = peripheral.wrap("right")
  3. modem.open(5)
  4. modem.open(4)
  5. local selected = nil
  6. local depthCounter = 1
  7.  
  8. function spin()
  9.     turtle.turnLeft()
  10.     turtle.turnLeft()
  11. end
  12.  
  13. function drop()
  14.     spin()
  15.     while turtle.detect() do
  16.         turtle.dig()
  17.     end
  18.     selected = turtle.getSelectedSlot()
  19.     turtle.select(16)
  20.     turtle.place()
  21.     for i = 1, 15 do
  22.         turtle.select(i)
  23.         turtle.drop()
  24.     end
  25.     turtle.select(16)
  26.     turtle.dig()
  27.     spin()
  28.     turtle.select(selected)
  29. end
  30.  
  31. function checkInv()
  32.     if turtle.getItemCount(15) > 0 then
  33.         drop()
  34.     end
  35. end
  36.  
  37. function strip()
  38.     for i = 1, length-1 do
  39.         if depth - depthCounter >= 3 then
  40.             while turtle.detectDown() do
  41.                 checkInv()
  42.                 turtle.digDown()
  43.             end
  44.             while turtle.detectUp() do
  45.                 checkInv()
  46.                 turtle.digUp()     
  47.             end
  48.             while turtle.detect() do
  49.                 checkInv()
  50.                 turtle.dig()
  51.             end
  52.             turtle.forward()       
  53.         elseif depth - depthCounter == 2 then
  54.             while turtle.detectUp() do
  55.                 checkInv()
  56.                 turtle.digUp()
  57.             end
  58.             while turtle.detect() do
  59.                 checkInv()
  60.                 turtle.dig()
  61.             end
  62.             turtle.forward()
  63.         elseif depth - depthCounter == 1 or depth - depthCounter <= 0  then
  64.             while turtle.detect() do
  65.                 checkInv()
  66.                 turtle.dig()
  67.             end
  68.             turtle.forward()
  69.         end
  70.     end
  71. end
  72.  
  73. function turn()
  74.     local count
  75.     if (depth-1) - depthCounter >= 3 then
  76.         count = 3
  77.     elseif (depth-1) - depthCounter == 2 then
  78.         count = 2
  79.     elseif (depth-1) - depthCounter == 1 then
  80.         count = 1
  81.     elseif (depth-1) - depthCounter <= 0 then
  82.         count = 0
  83.     end
  84.     while turtle.detectUp() do
  85.         checkInv()
  86.         turtle.digUp()
  87.     end
  88.     for i = 1, count do
  89.         while turtle.detectDown() do
  90.             checkInv()
  91.             turtle.digDown()
  92.         end
  93.         turtle.down()
  94.         depthCounter = depthCounter + 1
  95.     end
  96.     spin()
  97. end
  98.  
  99. function up()
  100.     print(depthCounter)
  101.     print(depth - depthCounter)
  102.     for i = 1, depth do
  103.         while turtle.detectUp() do
  104.             checkInv()
  105.             turtle.digUp()
  106.         end
  107.         turtle.up()
  108.     end
  109. end
  110.  
  111. function start()
  112.     while turtle.detectDown() do
  113.         checkInv()
  114.         turtle.digDown()
  115.     end
  116.     turtle.down()
  117. end
  118.  
  119. start()
  120. start()
  121. for i = 1, depth, 3 do
  122.     strip()
  123.     turn()
  124. end
  125. up()
  126. drop()
Add Comment
Please, Sign In to add comment