Advertisement
Karnel

dig_volume

Mar 18th, 2023 (edited)
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local args = {...}
  2. local lenght = tonumber(args[1])
  3. local width = tonumber(args[2])
  4. local hight = tonumber(args[3])
  5.  
  6. local ceil_hight = (hight - hight % 3) / 3
  7.  
  8.  
  9. local function do_line(distance)
  10.     local pos = 0
  11.     turtle.digUp()
  12.     turtle.digDown()
  13.     while pos < distance do
  14.         turtle.dig()
  15.         if turtle.forward() then
  16.             pos = pos + 1
  17.         end
  18.         turtle.digUp()
  19.         turtle.digDown()
  20.     end
  21. end
  22.  
  23.  
  24. local function do_flat(side)
  25.     for i=1, width do
  26.         do_line(lenght-1)
  27.         if i ~= width then
  28.             if i % 2 == side then
  29.                 turtle.turnRight()
  30.                 do_line(1)
  31.                 turtle.turnRight()
  32.             else
  33.                 turtle.turnLeft()
  34.                 do_line(1)
  35.                 turtle.turnLeft()
  36.             end
  37.         end
  38.     end
  39.    
  40. end
  41.  
  42.  
  43. local function do_volume()
  44.     for i=1, ceil_hight do
  45.         if width % 2 == 0 then
  46.             if i % 2 == 0 then
  47.                 do_flat(0)
  48.             else
  49.                 do_flat(1)
  50.             end
  51.         else
  52.             do_flat(1)
  53.         end
  54.         turtle.turnLeft()
  55.         turtle.turnLeft()
  56.         if i ~= ceil_hight then
  57.             local step_up = 1
  58.             while step_up <= 3 do
  59.                 turtle.digUp()
  60.                 if turtle.up() then
  61.                     step_up = step_up + 1
  62.                 end
  63.             end
  64.         end
  65.     end
  66. end
  67.  
  68.  
  69. local function come_back()
  70.     if ceil_hight % 2 == 0 then
  71.         print("x")
  72.     else
  73.         if width % 2 == 1 then
  74.             do_line(lenght-1)
  75.             turtle.turnRight()
  76.         else
  77.             turtle.turnLeft()
  78.         end
  79.         do_line(width-1)
  80.         turtle.turnRight()
  81.     end
  82.     local step_down = 1
  83.     while step_down < ceil_hight*3 -2 do
  84.         turtle.digDown()
  85.         if turtle.down() then
  86.             step_down = step_down + 1
  87.         end
  88.     end
  89. end
  90.  
  91. do_volume()
  92. come_back()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement