Advertisement
Ltven0mI

quary.lua

Mar 30th, 2023 (edited)
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Please enter width: ")
  2. local width = tonumber(read())
  3.  
  4. print("Please enter height: ")
  5. local height = tonumber(read())
  6.  
  7. print("Please enter depth: ")
  8. local depth = tonumber(read())
  9.  
  10. width = math.max(1, width)
  11. if (width % 2 == 0) then
  12.   width = width + 1
  13. end
  14.  
  15. height = math.max(1, height)
  16. depth = math.max(1, depth)
  17.  
  18. local yDir = "up"
  19. local dir = 0
  20.  
  21. function turnLeft()
  22.   dir = (dir + 3 % 4)
  23.   turtle.turnLeft()
  24. end
  25.  
  26. function turnRight()
  27.   dir = (dir + 1) % 4
  28.   turtle.turnRight()
  29. end
  30.  
  31. turtle.dig()
  32. turtle.forward()
  33. turnLeft()
  34.  
  35. for x=1, (width - 1) / 2 do
  36.     turtle.dig()
  37.     turtle.forward()
  38. end
  39.  
  40. turnRight()
  41. turnRight()
  42.  
  43. for z=1, depth do
  44.   for y=1, height do
  45.     for x=1, width - 1 do
  46.       turtle.dig()
  47.       turtle.forward()
  48.     end
  49.  
  50.     turnRight()
  51.     turnRight()
  52.  
  53.     if y < height then
  54.       if yDir == "up" then
  55.         turtle.digUp()
  56.         turtle.up()
  57.       elseif yDir == "down" then
  58.         turtle.digDown()
  59.         turtle.down()
  60.       end
  61.     end
  62.   end
  63.  
  64.   if yDir == "up" then
  65.     yDir = "down"
  66.   elseif yDir == "down" then
  67.     yDir = "up"
  68.   end
  69.  
  70.   if z < depth then
  71.     local inwardDir = dir
  72.  
  73.     if dir == 1 then
  74.       turnLeft()
  75.     elseif dir == 3 then
  76.       turnRight()
  77.     end
  78.  
  79.     turtle.dig()
  80.     turtle.forward()
  81.  
  82.     if inwardDir == 1 then
  83.       turnRight()
  84.     elseif inwardDir == 3 then
  85.       turnLeft()
  86.     end
  87.   end
  88. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement