BruceWplays

digV0.3

Sep 26th, 2022 (edited)
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.74 KB | None | 0 0
  1. hi = 25
  2. dep = 25
  3. wid = 25
  4.  
  5. whi = hi
  6. wdep = dep
  7. wwid = wid
  8.  
  9. if turtle.dig() then
  10. end
  11. turtle.forward()
  12. turtle.turnLeft()
  13.  
  14. secnd = 0
  15. stopdig = 0
  16. secndlk = 0
  17.  
  18. if hi / 2 == math.floor(hi / 2) then
  19.     turdigleft = 1
  20. elseif hi / 2 ~= math.floor(hi / 2) then
  21.     turdigleft = 0
  22. end
  23.  
  24.  
  25. local function mantudir()
  26.     secndlk = 0
  27.     if secnd == 1 then
  28.         if hi / 2 ~= math.floor(hi / 2) then
  29.             if turdigleft == 1 then
  30.                 turdigleft = 0
  31.             else
  32.                 turdigleft = 1
  33.             end
  34.         end
  35.         secnd = 0
  36.         secndlk = 1
  37.     end
  38.     if secndlk == 0 then
  39.         secnd = 1
  40.     end
  41. end
  42. local hidone = 0
  43.  
  44. local function redrawdig()
  45.     term.clear()
  46.     term.setCursorBlink(false)
  47.     term.setCursorPos(1,1)
  48.     print("Depth: "..wdep)
  49.     term.setCursorPos(1,2)
  50.     print("Hight: "..whi)
  51.     term.setCursorPos(1,3)
  52.     print("Width: "..wwid)
  53. end
  54. redrawdig()
  55. local function turncurdig()
  56.     if turdigleft == 0 then
  57.         turtle.turnRight()
  58.         mantudir()
  59.     else
  60.         turtle.turnLeft()
  61.         mantudir()
  62.     end
  63. end
  64. tddown = 1
  65. local function turndig()
  66.     local i = hi
  67.     while i > 1 do
  68.         if turtle.detectDown() then
  69.             turtle.digDown()
  70.         end
  71.         if turtle.down() then
  72.             i = i - 1
  73.             if i < 2 then
  74.                 tddown = 1
  75.             end
  76.         end
  77.     end
  78.     turncurdig()
  79.     while turtle.detect() do
  80.         turtle.dig()
  81.     end
  82.     turtle.forward()
  83.     turncurdig()
  84. end
  85.  
  86. while wdep > 0 do
  87.     if stopdig == 0 then
  88.     while whi > 0 do
  89.         while wwid > 1 do
  90.             while turtle.detect() do
  91.                 turtle.dig()
  92.             end
  93.             if turtle.forward() then
  94.                 wwid = wwid - 1
  95.             end
  96.             redrawdig()
  97.         end
  98.  
  99.         if whi > 1 then
  100.             while turtle.detectUp() do
  101.                 turtle.digUp()
  102.             end
  103.             if turtle.up() then
  104.                 hidone = hidone + 1
  105.             end
  106.             if turtle.turnLeft() then
  107.                 hidone = hidone + 1
  108.             end
  109.             if turtle.turnLeft() then
  110.                 hidone = hidone + 1
  111.             end
  112.         end
  113.  
  114.         wwid = wid
  115.         if hidone > 2 or whi < 2 then
  116.             whi = whi - 1
  117.         else
  118.             term.clear()
  119.             term.setCursorPos(1,1)
  120.             print("Error")
  121.             shell.exit()
  122.         end
  123.         hidone = 0
  124.         redrawdig()
  125.        
  126.     end
  127.     end
  128.     if wdep > 1 then
  129.         turndig()
  130.     end
  131.     if tddown > 0 or wdep < 2 then
  132.         wdep = wdep - 1
  133.         tddown = 0
  134.     end
  135.     if wdep < 1 then
  136.         stopdig = 1
  137.         break
  138.     end
  139.     whi = hi
  140.     redrawdig()
  141. end
Advertisement
Add Comment
Please, Sign In to add comment