Advertisement
Guest User

clear

a guest
Feb 23rd, 2021
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. local tool = require'import'
  2. local t = turtle
  3. local long = tonumber(arg[1])
  4. local larg= tonumber(arg[2])
  5. local h = tonumber(arg[3])
  6.  
  7.  
  8. function fr(long, h)
  9.     while long>1 do
  10.         turtle.dig()
  11.         while not t.forward() do t.dig() end
  12.         if h>1 then
  13.             turtle.digUp()
  14.         end
  15.         long = long-1
  16.     end
  17. end
  18.  
  19.  
  20. function virage(turn, h)
  21.     --0 turn left, 1 turn right
  22.     if turn == 0 then
  23.             turtle.turnLeft()
  24.             turtle.dig()
  25.             while not t.forward() do t.dig() end
  26.             if h>1 then
  27.                 turtle.digUp()
  28.             end
  29.             turtle.turnLeft()
  30.             turn = 1
  31.         else
  32.             turtle.turnRight()
  33.             turtle.dig()
  34.             while not t.forward() do t.dig() end
  35.             if h>1 then
  36.                 turtle.digUp()
  37.             end
  38.             turtle.turnRight()
  39.             turn = 0
  40.         end
  41.     return turn
  42. end
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. local turn=1
  50. local nh=0
  51. turtle.dig()
  52. while not t.forward() do t.dig() end
  53. if h>1 then
  54.     turtle.digUp()
  55. end
  56. repeat
  57.     print(h)
  58.     if nh==0 then
  59.         nh= nh+1
  60.     else
  61.         if h>1 then
  62.             turtle.digUp()
  63.             turtle.up()
  64.             h = h-1
  65.         end
  66.         if h>1 then
  67.             turtle.digUp()
  68.             turtle.up()
  69.             h = h-1
  70.         end
  71.     if h>1 then t.digUp() end
  72.     end
  73.  
  74.     l = 0
  75.     nh2 = 0
  76.     while l<larg do
  77.         if nh2==0 then
  78.             nh2=nh2+1
  79.         else
  80.             turn = virage(turn, h)
  81.         end
  82.         tool.needR()
  83.         fr(long, h)
  84.         l =l+1
  85.     end
  86.    
  87.    
  88.     turtle.turnLeft()
  89.     turtle.turnLeft()
  90. until h<=2
  91.  
  92.  
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement