Advertisement
oneoddbit

work - dig blocks

Feb 21st, 2022 (edited)
988
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. -- command line args  -  x, y, levels, updown, left, items
  2.  
  3. local x, y, levels, updown, left, items = tonumber(arg[1]), tonumber(arg[2]), tonumber(arg[3]), tonumber(arg[4]), tonumber(arg[5]), tonumber(arg[6])
  4.  
  5. function dig()
  6.     while turtle.inspect() do
  7.         turtle.dig()
  8.     end
  9.     turtle.forward()
  10.     if updown then
  11.         while turtle.inspectUp() do
  12.             turtle.digUp()
  13.         end
  14.         turtle.digDown()
  15.     end
  16. end
  17.  
  18. function move(num)
  19.     print(num)
  20.     for i = 1, tonumber(num) do
  21.         turtle.forward()
  22.     end
  23. end
  24.  
  25. for c = 1, levels do
  26.     for a = 1, x do
  27.         for b = 1, y do
  28.             if b < y then
  29.                 dig()
  30.             end
  31.         end
  32.         if a < x then
  33.             if left == 1 and a % 2 == 1 then
  34.                 turtle.turnLeft()
  35.                 dig()
  36.                 turtle.turnLeft()
  37.             elseif left == 1 and a % 2 == 0 then
  38.                 turtle.turnRight()
  39.                 dig()
  40.                 turtle.turnRight()
  41.             elseif left == 0 and a % 2 == 0 then
  42.                 turtle.turnLeft()
  43.                 dig()
  44.                 turtle.turnLeft()
  45.             else
  46.                 turtle.turnRight()
  47.                 dig()
  48.                 turtle.turnRight()
  49.             end
  50.         end
  51.         if items == 1 then
  52.             -- add items to ender chest
  53.             turtle.select(1)
  54.             turtle.placeUp()
  55.             for i = 16, 1, -1 do
  56.                 turtle.select(i)
  57.                 turtle.dropUp()
  58.             end
  59.             turtle.digUp()
  60.         end
  61.     end
  62.     -- returnToStartXY
  63.     -- if x is odd
  64.     if x % 2 == 1 then
  65.         print("x is odd moveY: "..y)
  66.         turtle.turnLeft()
  67.         turtle.turnLeft()
  68.         move(y)
  69.     end
  70.     -- if x is even and not left
  71.     if left == 0 then
  72.         print("not left: "..left)
  73.         turtle.turnRight()
  74.         move(x)
  75.         turtle.turnRight()
  76.     else
  77.         print("left: "..left)
  78.         turtle.turnLeft()
  79.         move(x)
  80.         turtle.turnLeft()
  81.     end
  82.    
  83.     if c < levels then
  84.         turtle.down()
  85.         turtle.digDown()
  86.         if updown then
  87.             for i = 1, 2 do
  88.                 turtle.down()
  89.                 turtle.digDown()
  90.             end
  91.         end
  92.     end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement