Razara

chess King

May 19th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.99 KB | None | 0 0
  1. --TODO: add return to start
  2.  
  3. tArgs = {...}
  4. color = tArgs[1]
  5. function select(i)
  6.     turtle.select(i+ (color == "white" and 0 or 6))
  7. end
  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.     turtle.back()
  34.     turtle.back()
  35.     turtle.turnLeft()
  36.     turtle.forward()
  37.     turtle.forward()
  38.    
  39.     for i = 1,6 do
  40.         turtle.up()
  41.         turtle.placeDown()
  42.     end
  43.    
  44.     select(6)
  45.     turtle.up()
  46.     turtle.placeDown()
  47.     turtle.up()
  48.     turtle.placeDown()
  49.    
  50.     turtle.back()
  51.     turtle.back()
  52.     turtle.down()
  53.     turtle.down()
  54.    
  55.     sideDown()
  56.     turnCorner()
  57.     sideUp()
  58.     turnCorner()
  59.     sideDown()
  60.     turnCorner()
  61.     sideUp()
  62.  
  63. end
  64.  
  65.  function turnCorner()
  66.         turtle.turnRight()
  67.         turtle.forward()
  68.         turtle.forward()
  69.         turtle.turnLeft()
  70.         turtle.forward()
  71.         turtle.forward()
  72.         turtle.turnLeft()
  73.  end
  74.  
  75.  function sideUp()
  76.  
  77.     select(2)
  78.     turtle.forward()
  79.     turtle.turnLeft()
  80.     turtle.place()
  81.     turtle.turnRight()
  82.     turtle.back()
  83.     turtle.place()
  84.     turtle.up()
  85.  
  86.     select(3)
  87.     turtle.place()
  88.     turtle.up()
  89.  
  90.     select(4)
  91.     turtle.place()
  92.     turtle.up()
  93.    
  94.        
  95.     select(5)
  96.     turtle.place()
  97.     turtle.up()
  98.    
  99.        
  100.     select(3)
  101.     turtle.place()
  102.     turtle.up()
  103.  
  104.     select(2)
  105.     turtle.forward()
  106.     turtle.turnLeft()
  107.     turtle.place()
  108.     turtle.turnRight()
  109.     turtle.back()
  110.     turtle.place()
  111.     turtle.up()
  112.    
  113.     turtle.forward()
  114.     turtle.turnLeft()
  115.     turtle.place()
  116.     turtle.turnRight()
  117.     turtle.back()
  118. end
  119.  
  120. function sideDown()
  121.    
  122.    
  123.     select(2)
  124.     turtle.forward()
  125.     turtle.turnLeft()
  126.     turtle.place()
  127.     turtle.turnRight()
  128.     turtle.back()
  129.  
  130.     turtle.down()
  131.     turtle.forward()
  132.     turtle.turnLeft()
  133.     turtle.place()
  134.     turtle.turnRight()
  135.     turtle.back()
  136.     turtle.place()
  137.    
  138.     select(3)
  139.     turtle.down()
  140.     turtle.place()
  141.    
  142.     select(5)
  143.     turtle.down()
  144.     turtle.place()
  145.    
  146.     select(4)
  147.     turtle.down()
  148.     turtle.place()
  149.    
  150.     select(3)
  151.     turtle.down()
  152.     turtle.place()
  153.    
  154.     select(2)
  155.     turtle.down()
  156.     turtle.forward()
  157.     turtle.turnLeft()
  158.     turtle.place()
  159.     turtle.turnRight()
  160.     turtle.back()
  161.     turtle.place()
  162. end
  163.  
  164. function returnToStart()
  165.  
  166.     for i = 1,6 do
  167.         turtle.down()
  168.     end
  169.    
  170.     turtle.turnLeft()
  171.     turtle.forward()
  172.     turtle.forward()
  173.     turtle.turnRight()
  174. end
  175.  
  176. buildBase()
  177. buildMid()
  178. returnToStart()
Advertisement
Add Comment
Please, Sign In to add comment