mjmac85

9x9 read notes

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