Advertisement
jdroid91

Spiral.lua

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