Advertisement
HiggsBroson

Untitled

Nov 27th, 2020 (edited)
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. arg = {...}
  2.  
  3. local function turnLeft(num)
  4.     for i = 1, num do
  5.         turtle.turnLeft()
  6.     end
  7. end
  8.  
  9. function loop()
  10.     if #arg > 2 then
  11.         w = tonumber(arg[1])
  12.         h = tonumber(arg[2])
  13.         l = tonumber(arg[3])
  14.        
  15.         local x = 0
  16.         local y = 0
  17.         local z = 0
  18.         local steps = 0
  19.         orientation = getOrientation()
  20.         while steps < w * h * l do
  21.             if (orientation ~= 3) then
  22.            
  23.             end
  24.            
  25.             if (x < w - 1) then
  26.                 turtle.dig()
  27.                 turtle.forward()
  28.                 x = x + 1
  29.                 steps = steps + 1
  30.             else
  31.                 if (z < l - 1) then
  32.                     if (z % 2 == 0) then
  33.                         turtle.turnRight()
  34.                     else
  35.                         turtle.turnLeft()
  36.                     end
  37.                     turtle.dig()
  38.                     turtle.forward()
  39.                     steps = steps + 1
  40.                     if (z % 2 == 0) then
  41.                         turtle.turnRight()
  42.                     else
  43.                         turtle.turnLeft()
  44.                     end
  45.                     x = 0
  46.                     z = z + 1
  47.                 else
  48.                     if (y < h - 1) then
  49.                         turnLeft(3)
  50.                         turtle.digDown()
  51.                         turtle.down()
  52.                         steps = steps + 1
  53.                         x = 0
  54.                         z = 0
  55.                         y = y + 1
  56.                     else
  57.                         break
  58.                     end
  59.                 end
  60.             end
  61.         end
  62.     end
  63. end
  64.  
  65. function getOrientation()
  66.     loc1 = vector.new(gps.locate(2, false))
  67.     steps = 1
  68.     if (not turtle.forward()) then
  69.         for i = 1, 6 do
  70.             steps = steps + 1
  71.             if (not turtle.forward()) then
  72.                 turtle.dig()
  73.             else
  74.                 break
  75.             end
  76.         end
  77.     end
  78.     loc2 = vector.new(gps.locate(2, false))
  79.     turnLeft(2)
  80.     turtle.forward(2)
  81.     turnLeft(2)
  82.     heading = loc2 - loc1
  83.     return ((heading.x + math.abs(heading.x) * 2) + (heading.z + math.abs(heading.z) * 3))
  84. end
  85.  
  86. loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement