Advertisement
jdroid91

SpiralNew.Lua

Oct 1st, 2023 (edited)
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local function checkFuel()
  2.     repeat
  3.         os.sleep(1)
  4.     until turtle.getFuelLevel() <= 2000
  5.     turtle.refuel(turtle.getItemCount(1)-1)
  6. end
  7.  
  8. local function mineLayer ()
  9.     local maxLength = 10
  10.     turtle.digDown()
  11.     turtle.down()
  12.     local currentLength = maxLength
  13.  
  14.     while (currentLength > 0)
  15.     do
  16.         local index2 = 0
  17.         while (index2 < 4)
  18.         do
  19.             local index = 0
  20.             if ((index == 0 and index2 == 3) or (currentLength < maxLength and index2 == 1))
  21.             then
  22.                 currentLength = currentLength - 1
  23.             end
  24.             while (index < currentLength)
  25.             do
  26.                 while (turtle.detect())
  27.                 do
  28.                     turtle.dig()
  29.                     os.sleep(0.5)
  30.                 end
  31.                 turtle.forward()
  32.                 index = index + 1
  33.             end
  34.             turtle.turnRight()
  35.             index2 = index2 + 1
  36.         end
  37.     end
  38.     turtle.turnLeft()
  39.     local halfMax = (maxLength / 2) - 1
  40.     local index = 0;
  41.     while (index < halfMax)
  42.     do
  43.         turtle.forward()
  44.         index = index + 1
  45.     end
  46.     turtle.turnLeft()
  47.     local index = 0
  48.     while (index < halfMax)
  49.     do
  50.         turtle.forward()
  51.         index = index + 1
  52.     end
  53.     turtle.turnLeft()
  54.     turtle.turnLeft()    
  55. end
  56.  
  57. local layersToDig = 50
  58. local layer = 0
  59. while (layer < layersToDig)
  60. do
  61.     parallel.waitForAny(mineLayer, checkFuel)
  62.     layer = layer + 1
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement