Razara

chess Rook

May 18th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.81 KB | None | 0 0
  1.  --TODO: return to start is not same as others
  2.  tArgs = {...}
  3. color = tArgs[1]
  4. function select(i)
  5.     turtle.select(i+ (color == "white" and 0 or 6))
  6. end
  7.  
  8. function buildBase()
  9.         select(1)
  10.         for y = 1,5 do
  11.                 for x = 1,4 do
  12.                                         turtle.placeDown()
  13.                                         turtle.forward()
  14.                 end
  15.             if y < 5 then
  16.                 if y%2 ~= 0 then
  17.                                         turtle.turnRight()
  18.                                         turtle.placeDown()
  19.                                         turtle.forward()
  20.                                         turtle.turnRight()
  21.                 else
  22.                                         turtle.turnLeft()
  23.                                         turtle.placeDown()
  24.                                         turtle.forward()
  25.                                         turtle.turnLeft()
  26.                 end
  27.                         end
  28.         end
  29.         turtle.placeDown()
  30. end
  31.  
  32. function buildMid()
  33.  
  34.         turtle.back()
  35.         turtle.turnLeft()
  36.         turtle.forward()
  37.  
  38.         for i = 1,4 do
  39.                         turtle.up()
  40.                         turtle.placeDown()
  41.         end
  42.  
  43.         turtle.forward()
  44.         turtle.forward()
  45.         turtle.down()
  46.  
  47.         for i = 1,3 do
  48.                         turtle.down()
  49.                         turtle.placeUp()
  50.         end
  51.        
  52.         turtle.turnRight()
  53.         turtle.back()
  54.         turtle.place()
  55.        
  56.         turtle.back()
  57.        
  58.         for i = 1,4 do
  59.             turtle.up()
  60.             turtle.placeDown()
  61.         end
  62.        
  63.         turtle.turnLeft()      
  64.         turtle.back()
  65.                 turtle.back()
  66.         turtle.down()
  67.                
  68.         for i = 1,3 do
  69.                         turtle.down()
  70.                         turtle.placeUp()
  71.         end
  72.        
  73.         turtle.turnLeft()
  74.         turtle.back()
  75.         turtle.place()
  76.        
  77.         turtle.turnLeft()
  78.         turtle.back()
  79.        
  80.         for i = 1,4 do
  81.                         turtle.up()
  82.                         turtle.placeDown()
  83.         end
  84. end
  85.  
  86.  function turnCorner()
  87.         turtle.turnRight()
  88.         turtle.forward()
  89.         turtle.forward()
  90.         turtle.turnLeft()
  91.         turtle.forward()
  92.         turtle.forward()
  93.         turtle.turnLeft()
  94.  end
  95.  
  96.  function addCovers()
  97.         select(3)
  98.         turtle.back()
  99.         turtle.back()
  100.        
  101.         for i = 1,4 do
  102.                         turtle.down()
  103.                         turtle.place()
  104.         end
  105.        
  106.         turnCorner()
  107.          
  108.         for i = 1,4 do
  109.             turtle.place()
  110.             turtle.up()
  111.         end
  112.        
  113.         turnCorner()
  114.        
  115.         for i = 1,4 do
  116.             turtle.down()
  117.             turtle.place()
  118.         end
  119.        
  120.         turnCorner()
  121.          
  122.         for i = 1,4 do
  123.             turtle.place()
  124.             turtle.up()
  125.         end
  126.  end
  127.  
  128.  function buildTop()
  129.         select(2)
  130.         turtle.up()
  131.         turtle.turnLeft()
  132.        
  133.         turtle.placeDown()
  134.         turtle.forward()
  135.         turtle.placeDown()
  136.         turtle.forward()
  137.         turtle.placeDown()
  138.  
  139.         for j = 1,3 do
  140.         turtle.turnRight()
  141.         for i = 1,4 do
  142.                 turtle.forward()
  143.                 turtle.placeDown()
  144.         end
  145.         end
  146.  
  147.         turtle.turnRight()
  148.         turtle.forward()
  149.         turtle.placeDown()
  150.         turtle.turnRight()
  151.        
  152.         turtle.forward()
  153.         select(3)
  154.         for y = 1,3 do
  155.                 for x = 1,2 do
  156.                                         turtle.placeDown()
  157.                                         turtle.forward()
  158.                 end
  159.             if y < 3 then
  160.                 if y%2 == 0 then
  161.                                         turtle.turnRight()
  162.                                         turtle.placeDown()
  163.                                         turtle.forward()
  164.                                         turtle.turnRight()
  165.                 else
  166.                                         turtle.turnLeft()
  167.                                         turtle.placeDown()
  168.                                         turtle.forward()
  169.                                         turtle.turnLeft()
  170.                 end
  171.             end
  172.         end
  173.         turtle.placeDown()
  174.        
  175.         select(2)
  176.         turtle.forward()
  177.         turtle.turnRight()
  178.         turtle.back()
  179.         turtle.up()
  180.        
  181.         for i = 1,4 do
  182.             turtle.placeDown()
  183.             turtle.forward()
  184.             turtle.forward()
  185.             turtle.placeDown()
  186.             turtle.forward()
  187.             turtle.forward()
  188.             turtle.placeDown()
  189.             turtle.turnRight()
  190.         end
  191.    
  192.  end
  193.  
  194.  function returnToStart()
  195.     for i = 1,4 do
  196.         turtle.forward()
  197.     end
  198.     turtle.turnRight()
  199.     turtle.back()
  200.     for i = 1,6 do
  201.         turtle.down()
  202.     end
  203.     turtle.forward()
  204.  end
  205.  
  206. buildBase()
  207. buildMid()
  208. addCovers()
  209. buildTop()
  210. returnToStart()
Advertisement
Add Comment
Please, Sign In to add comment