Cwackers

Room Dig No Fuel

Mar 26th, 2022 (edited)
1,287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local args = {...}
  2.  
  3.  
  4.  
  5. if not #args == 3 then
  6.   print("Usage: clear <x y z>")
  7.   return
  8. end
  9.  
  10. function checkInv()
  11.   isFull = true
  12.  
  13.   for i=1,15 do
  14.     if turtle.getItemCount(i) == 0 then
  15.       isFull = false
  16.     end
  17.   end
  18.  
  19.   if isFull == true then
  20.     shell.run("emptyI")
  21.   end
  22. end
  23.  
  24. local y = tonumber(args[1])
  25. local x = tonumber(args[2]) - 1
  26. local z = tonumber(args[3])
  27.  
  28. if x == nil or y == nil or z == nil then
  29.   print("Invalid dimensions")
  30.   return
  31. end
  32.  
  33. if x < 0 or y < 0 or z < 0 then
  34.   print("Invalid (negative) dimensions")
  35.   return
  36. end
  37.  
  38. local direction = true
  39. for i = 1, z do
  40.   for j = 1, y do
  41.     for k = 1, x do
  42.  
  43.  
  44.       turtle.dig()
  45.       while not turtle.forward() do turtle.dig() end
  46.       checkInv()
  47.  
  48.  
  49.     end
  50.     if j < y then
  51.       if direction then
  52.         turtle.turnRight()
  53.         turtle.dig()
  54.         while not turtle.forward() do turtle.dig() end
  55.         turtle.turnRight()
  56.         direction = false
  57.       else
  58.         turtle.turnLeft()
  59.         turtle.dig()
  60.         while not turtle.forward() do turtle.dig() end
  61.         turtle.turnLeft()
  62.         direction = true
  63.       end
  64.     end
  65.   end
  66.   if i < z then
  67.     turtle.digDown()
  68.     while not turtle.down() do turtle.digDown() end
  69.     turtle.turnRight()
  70.     turtle.turnRight()
  71.   end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment