mjmac85

Turtle return Completed

Mar 24th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. print("Direwolf20's 9x9 House builder")
  2. print("Slots 1-3 = Walls (?? Stacks)")
  3. print("Slot 4 = Floor (?? blocks)")
  4. print("Slot 5 = Ceiling Middle (?? blocks)")
  5. print("Slot 6 = Glass (16 blocks)")
  6.  
  7.  
  8.  
  9.  
  10.  
  11. local function checkCount(slot)
  12.     if turtle.getItemCount(slot) == 0 then
  13.         slot = slot + 1
  14.         turtle.select(slot)
  15.         return slot
  16.     end
  17.     return slot
  18. end
  19.  
  20. local function tryRefuel(slot)
  21.     if turtle.getFuelLevel() <= 5 then
  22.         turtle.select(16)
  23.         turtle.refuel(4)
  24.         turtle.select(slot)
  25.  
  26.     end
  27. end
  28.  
  29. local function floor(slot)
  30. --Does 4 passes.  One up and one down for 8 rows.
  31. --Leaves the 9th row empty to start the walls
  32.     turtle.select(slot) --Selects cobble for floor
  33.     for j = 0, 3 do
  34.         for i = 0, 8 do --Does one row up and another back
  35.             tryRefuel(slot)
  36.             slot = checkCount(slot)
  37.             turtle.placeDown()
  38.             turtle.forward()
  39.         end
  40.         turtle.turnRight()
  41.         turtle.forward()
  42.         turtle.turnRight()
  43.         turtle.forward()
  44.         for i = 0, 8 do
  45.             tryRefuel(slot)
  46.             slot = checkCount(slot)
  47.             turtle.placeDown()
  48.             turtle.forward()
  49.         end
  50.         turtle.turnLeft()
  51.         turtle.forward()
  52.         turtle.turnLeft()
  53.         turtle.forward()
  54.     end
  55.     return(slot)
  56.  
  57. end
  58.  
  59. local function walls(slot)
  60. --Starts on the last row of the floors as the first wall
  61.    
  62.     for j = 0, 8 do
  63.         --places 6 blocks up on the first wall missing the floor
  64.         for i = 0, 6 do
  65.             tryRefuel(slot)
  66.             slot = checkCount(slot)
  67.             turtle.placeDown()
  68.             turtle.up()
  69.         end
  70.         turtle.forward()
  71.         for i = 0, 6 do
  72.             tryRefuel(slot)
  73.             slot = checkCount(slot)
  74.             turtle.down()
  75.         end
  76.     end
  77.     -- places it back onto the floor for the second wall.
  78.     -- possibly loop this twice and finish with a seperate door piece?
  79.     for k = 0, 1 do
  80.         turtle.turnLeft()
  81.         turtle.forward()
  82.         turtle.turnLeft()
  83.         turtle.forward()
  84.         turtle.turnRight()
  85.         for j = 0, 7 do
  86.             --places 5 blocks up from the floor
  87.             for i = 0, 6 do
  88.                 tryRefuel(slot)
  89.                 slot = checkCount(slot)
  90.                 turtle.placeDown()
  91.                 turtle.up()
  92.             end
  93.             turtle.forward()
  94.             for i = 0, 6 do
  95.                 tryRefuel(slot)
  96.                 slot = checkCount(slot)
  97.                 turtle.down()
  98.             end
  99.         end
  100.     end
  101.     turtle.turnLeft()
  102.     turtle.forward()
  103.     turtle.turnLeft()
  104.     turtle.forward()
  105.     turtle.turnRight()
  106.     --Last wall with the door does a column of 3 then a door then repeats
  107.             for j = 0, 2 do
  108.                 --places 5 blocks up from the floor
  109.                 for i = 0, 6 do
  110.                     tryRefuel(slot)
  111.                     slot = checkCount(slot)
  112.                     turtle.placeDown()
  113.                     turtle.up()
  114.                 end
  115.                 turtle.forward()
  116.                 for i = 0, 6 do
  117.                     tryRefuel(slot)
  118.                     slot = checkCount(slot)
  119.                     turtle.down()
  120.                 end
  121.             end
  122.             ---------------------
  123.             --Door is placed here
  124.             turtle.up()
  125.             turtle.up()
  126.             ---------------------
  127.             for i = 0, 4 do
  128.                     tryRefuel(slot)
  129.                     slot = checkCount(slot)
  130.                     turtle.placeDown()
  131.                     turtle.up()
  132.                 end
  133.                 turtle.forward()
  134.                 for i = 0, 6 do
  135.                     tryRefuel(slot)
  136.                     slot = checkCount(slot)
  137.                     turtle.down()
  138.                 end
  139.            
  140.            
  141.             --Finished out the row of columns
  142.             for j = 0, 2 do
  143.                 --places 5 blocks up from the floor
  144.                 for i = 0, 6 do
  145.                     tryRefuel(slot)
  146.                     slot = checkCount(slot)
  147.                     turtle.placeDown()
  148.                     turtle.up()
  149.                 end
  150.                 turtle.forward()
  151.                 for i = 0, 6 do
  152.                     tryRefuel(slot)
  153.                     slot = checkCount(slot)
  154.                     turtle.down()
  155.                 end
  156.             end
  157.    
  158.     end
  159.  
  160. local function roof(slot)
  161.     turtle.turnLeft()
  162.     turtle.forward()
  163.     turtle.turnLeft()
  164.     turtle.forward()
  165.     print("enter loop")
  166.     for j = 0, 2 do
  167.         for i = 0, 8 do
  168.             tryRefuel(slot)
  169.             slot = checkCount(slot)
  170.             turtle.placeDown()
  171.             print("place down")
  172.             turtle.forward()
  173.             print("forward")
  174.         end
  175.         turtle.turnRight()
  176.         turtle.forward()
  177.         turtle.turnRight()
  178.         for i = 0, 8 do
  179.             tryRefuel(slot)
  180.             slot = checkCount(slot)
  181.             turtle.placeDown()
  182.             turtle.forward()
  183.         end
  184.         turtle.turnLeft()
  185.         turtle.forward()
  186.         turtle.turnLeft()
  187.     end
  188.     for i = 0, 8 do
  189.             tryRefuel(slot)
  190.             slot = checkCount(slot)
  191.             turtle.placeDown()
  192.             turtle.forward()
  193.     end
  194.    
  195. end
  196.  
  197. --Control Section
  198. --Starts with slot 1 for cobble
  199. local function control()
  200.     slot = 1
  201.     tryRefuel(slot)
  202.     slot = checkCount(slot)
  203. --  turtle.up()
  204. --  floor(slot)
  205. --  walls(slot)
  206.     roof(slot)
  207. end
  208.  
  209. control()
Advertisement
Add Comment
Please, Sign In to add comment