Razara

chess Pawn

May 19th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 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.  
  9.  
  10. function buildBase()
  11.         select(1)
  12.         for y = 1,5 do
  13.                 for x = 1,4 do
  14.                                         turtle.placeDown()
  15.                                         turtle.forward()
  16.                 end
  17.             if y < 5 then
  18.                 if y%2 ~= 0 then
  19.                                         turtle.turnRight()
  20.                                         turtle.placeDown()
  21.                                         turtle.forward()
  22.                                         turtle.turnRight()
  23.                 else
  24.                                         turtle.turnLeft()
  25.                                         turtle.placeDown()
  26.                                         turtle.forward()
  27.                                         turtle.turnLeft()
  28.                 end
  29.                         end
  30.         end
  31.         turtle.placeDown()
  32. end
  33.  
  34.  
  35. function buildMid()
  36.     turtle.back()
  37.     turtle.back()
  38.     turtle.turnLeft()
  39.     turtle.forward()
  40.     turtle.forward()
  41.    
  42.     for i = 1,4 do
  43.         turtle.up()
  44.         turtle.placeDown()
  45.     end
  46.    
  47.     select(4)
  48.     turtle.up()
  49.     turtle.placeDown()
  50.    
  51.     turtle.back()
  52.     turtle.back()
  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(4)
  78.     turtle.place()
  79.     turtle.up()
  80.     turtle.place()
  81.     turtle.up()
  82.    
  83.     select(2)
  84.     turtle.place()
  85.     turtle.turnRight()
  86.     turtle.forward()
  87.     turtle.turnLeft()
  88.     turtle.place()
  89.     turtle.turnLeft()
  90.     turtle.forward()
  91.     turtle.turnRight()
  92.     turtle.up()
  93.  
  94.     select(4)
  95.     turtle.place()
  96.     turtle.up()
  97.  
  98.  
  99. end
  100.  
  101. function sideDown()
  102.    
  103.     select(4)
  104.     turtle.down()
  105.     turtle.place()
  106.    
  107.     select(2)
  108.     turtle.down()
  109.     turtle.place()
  110.     turtle.turnRight()
  111.     turtle.forward()
  112.     turtle.turnLeft()
  113.     turtle.place()
  114.     turtle.turnLeft()
  115.     turtle.forward()
  116.     turtle.turnRight()
  117.  
  118.     select(4)
  119.     turtle.down()
  120.     turtle.place()
  121.     turtle.down()
  122.     turtle.place()
  123.    
  124. end
  125.  
  126. function returnToStart()
  127.  
  128.     for i = 1,4 do
  129.     turtle.down()
  130.     end
  131.     turtle.turnLeft()
  132.     turtle.forward()
  133.     turtle.forward()
  134.     turtle.turnRight()
  135. end
  136.  
  137. buildBase()
  138. buildMid()
  139. returnToStart()
Advertisement
Add Comment
Please, Sign In to add comment