Advertisement
Guest User

mainProg

a guest
Apr 24th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sendID, msg, prot = rednet.receive()
  2.  
  3. function move(direction)
  4.   if direction == "up" then
  5.  
  6.     while turtle.up() == false do
  7.       turtle.digUp()
  8.       turtle.attackUp()
  9.     end
  10.    
  11.   elseif direction == "down" then
  12.  
  13.     while turtle.down() == false do
  14.       turtle.digDown()
  15.       turtle.attackDown()
  16.     end
  17.    
  18.   elseif direction == "forward" then
  19.  
  20.     while turtle.forward() == false do
  21.       turtle.dig()
  22.       turtle.attack()
  23.     end
  24.   end
  25. end
  26.  
  27. if msg[1] == "cube" then
  28.  
  29.   frontBlocks = msg[2]
  30.   rightBlocks = msg[3]
  31.   upBlocks = msg[4]
  32.  
  33.   turtle.dig()
  34.   move("forward")
  35.    
  36.   function line()
  37.     for i=1,frontBlocks -1 do
  38.       turtle.dig()
  39.       move("forward")
  40.     end
  41.   end
  42.    
  43.   function panel()
  44.     line()
  45.     for i=1,upBlocks -1 do
  46.       turtle.digUp()
  47.       move("up")
  48.       turtle.turnRight()
  49.       turtle.turnRight()
  50.       line()
  51.     end
  52.   end
  53.    
  54.   function turn()
  55.     turtle.turnLeft()
  56.     turtle.dig()
  57.     turtle.select(1)
  58.     turtle.place()
  59.    
  60.     for i=1,16 do
  61.       turtle.select(i)
  62.       turtle.drop()
  63.     end
  64.    
  65.     turtle.select(1)
  66.     turtle.dig()
  67.     move("forward")
  68.     turtle.turnLeft()
  69.   end
  70.    
  71.   function cuboid()
  72.     panel()
  73.     m = 0
  74.     for i=1,rightBlocks -1 do
  75.       m = m + 1
  76.       if m == 1 and upBlocks%2 == 1 then
  77.         m = 0
  78.         turtle.turnRight()
  79.         turtle.turnRight()
  80.         for i=1,frontBlocks - 1 do
  81.           move("forward")
  82.         end
  83.         for i=1,upBlocks - 1 do
  84.           move("down")
  85.         end
  86.         turn()
  87.         panel()
  88.       elseif math.fmod(upBlocks,2) ~= 1 then
  89.         turtle.turnLeft()
  90.        
  91.         for i=1,upBlocks - 1 do
  92.           move("down")
  93.         end
  94.        
  95.         turtle.dig()
  96.         move("forward")
  97.         turtle.turnLeft()
  98.         panel()
  99.        
  100.       end
  101.     end
  102.   end
  103.    
  104.   cuboid()
  105.   if math.fmod(upBlocks,2) ~= 1 then
  106.     turtle.turnRight()
  107.     for i=1,upBlocks - 1 do
  108.       move("down")
  109.     end
  110.    
  111.     for i=1,rightBlocks - 1 do
  112.       move("forward")
  113.     end
  114.   else
  115.     turtle.turnRight()
  116.     turtle.turnRight()
  117.    
  118.     for i=1,frontBlocks - 1 do
  119.       move("forward")
  120.     end
  121.    
  122.     turtle.turnRight()
  123.    
  124.     for i=1,upBlocks - 1 do
  125.       move("down")
  126.     end
  127.    
  128.     for i=1,rightBlocks - 1 do
  129.       move("forward")
  130.     end
  131.   end
  132.    
  133.   turtle.turnLeft()
  134.   turtle.dig()
  135.   turtle.select(1)
  136.   turtle.place()
  137.    
  138.   for i=1,16 do
  139.     turtle.select(i)
  140.     turtle.drop()
  141.   end
  142.   turtle.select(1)
  143.   turtle.dig()
  144.  
  145.  
  146. elseif msg[1] == "tree" then
  147.   move("forward")
  148.  
  149.   moved = 0
  150.  
  151.   while turtle.digUp() == true do
  152.     move("up")
  153.     moved = moved + 1
  154.   end
  155.  
  156.   while moved > 0 do
  157.     move("down")
  158.     moved = moved - 1
  159.   end
  160.  
  161. elseif msg[1] == "move" then
  162.   moveBlocks = msg[3]
  163.  
  164.   while moveBlocks > 0 do
  165.     if msg[2] == "up" then
  166.       move("up")
  167.    
  168.     elseif msg[2] == "down" then
  169.       move("down")
  170.      
  171.     elseif msg[2] == "forward" then
  172.       move("forward")
  173.    
  174.     end
  175.   end
  176. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement