Mowmaster

Quarry2 1.4

Aug 31st, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. local lmax,wmax,hmax,d=...
  2.  
  3. local l=0
  4. local h=0
  5. local w=1
  6. local f=0
  7.  
  8. function Left(lt)
  9.     while lt~=0 do
  10.         turtle.turnLeft()
  11.         lt=lt-1
  12.     end
  13. end
  14.  
  15. function Right(rt)
  16.     while rt~=0 do
  17.         turtle.turnRight()
  18.         rt=rt-1
  19.     end
  20. end
  21.  
  22. function layer()
  23.     turtle.digUp()
  24.     turtle.digDown()
  25.     Right(1)
  26.     turtle.dig()
  27.     Left(2)
  28.     turtle.dig()
  29.     Right(1)
  30. end
  31.  
  32. function down()
  33.     for h=0,hmax do
  34.         layer()
  35.         turtle.digDown()
  36.         turtle.down()
  37.         h=h+1
  38.     end
  39. end
  40.  
  41. function up()
  42.     for h=0,hmax do
  43.         layer()
  44.         turtle.digUp()
  45.         turtle.up()
  46.         h=h+1
  47.     end
  48. end
  49.  
  50. function store()
  51.     turtle.select(1)
  52.     turtle.digUp()
  53.     turtle.placeUp()
  54.     for s=2,16 do
  55.         turtle.select(s)
  56.         turtle.dropUp()
  57.     end
  58.     turtle.select(1)
  59.     turtle.digUp()
  60. end
  61.  
  62.  
  63.  
  64. function length()
  65.     while l~=lmax do
  66.         down()
  67.         layer()
  68.         store()
  69.         turtle.dig()
  70.         turtle.forward()
  71.         l=l+1
  72.         up()
  73.         layer()
  74.         store()
  75.         if l~=lmax then
  76.             turtle.dig()
  77.             turtle.forward()
  78.             l=l+1
  79.         end
  80.     end
  81. end
  82.  
  83. function align()
  84.     print("Moving into position")
  85.     print(lmax,':',l,':',wmax,':',w,':',hmax,':',h,':R0L1',direction)
  86.     if d==0 then
  87.         Right(1)
  88.     end
  89.     if d==1 then
  90.         Left(1)
  91.     end
  92.     turtle.forward()
  93.     if d==0 then
  94.         Left(1)
  95.     end
  96.     if d==1 then
  97.         Right(1)
  98.     end
  99.     w=w+1
  100. end
  101.  
  102. function turn()
  103. f=0
  104.     if d==0 then
  105.         Right(1)
  106.         if w~=wmax-1 then
  107.             turtle.dig()
  108.             turtle.forward()
  109.             w=w+1
  110.         else
  111.             f=f+1
  112.         end
  113.         if w~=wmax-1 then
  114.             turtle.dig()
  115.             turtle.forward()
  116.             w=w+1
  117.         else
  118.             f=f+1
  119.         end
  120.         if w~=wmax-1 then
  121.             turtle.dig()
  122.             turtle.forward()
  123.             w=w+1
  124.         else
  125.             f=f+1
  126.         end
  127.         d=1
  128.     end
  129.     if d==1 then
  130.         Left(1)
  131.         if w~=wmax-1 then
  132.             turtle.dig()
  133.             turtle.forward()
  134.             w=w+1
  135.         else
  136.             f=f+1
  137.         end
  138.         if w~=wmax-1 then
  139.             turtle.dig()
  140.             turtle.forward()
  141.             w=w+1
  142.         else
  143.             f=f+1
  144.         end
  145.         if w~=wmax-1 then
  146.             turtle.dig()
  147.             turtle.forward()
  148.             w=w+1
  149.         else
  150.             f=f+1
  151.         end
  152.         d=0
  153.     end
  154. end
  155.  
  156.  
  157. align()
  158. while f~=3 do
  159.     length()
  160.     turn()
  161. end
Add Comment
Please, Sign In to add comment