Slord6

Untitled

Jun 25th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.25 KB | None | 0 0
  1. --block in front of turtle at beginning is bottom left corner
  2. --when viewed from above
  3. -- 1 = Wall
  4. -- 2 = Roof
  5. -- 3 = Door
  6. -- 4 = Chest
  7. -- 5 = Furnace
  8. -- 6 = Bed
  9.  
  10. -- 16 = Fuel
  11.  
  12. local wallIndex = 1
  13. local roofIndex = 2
  14. local doorIndex = 3
  15. local chestIndex = 4
  16. local furnaceIndex = 5
  17. local bedIndex = 6
  18. local fuelIndex = 16
  19.  
  20. function forceMoveLeft()
  21.     turtle.turnLeft()
  22.     forceMoveForward()
  23.     turtle.turnRight()
  24. end
  25.  
  26. function forceTurnLeft()
  27.     turtle.turnLeft()
  28.     forceMoveForward()
  29. end
  30.  
  31. function forceMoveRight()
  32.     turtle.turnRight()
  33.     forceMoveForward()
  34.     turtle.turnLeft()
  35. end
  36.  
  37. function forceMoveUp()
  38.     while not turtle.up() do
  39.         turtle.digUp()
  40.     end
  41. end
  42.  
  43. function forceMoveDown()
  44.     while not turtle.down() do
  45.         turtle.digDown()
  46.     end
  47. end
  48.  
  49. function forceMoveBack()
  50.     turtle.turnLeft()
  51.     turtle.turnLeft()
  52.     forceMoveForward()
  53.     turtle.turnLeft()
  54.     turtle.turnLeft()
  55. end
  56.  
  57. function forceMoveForward()
  58.     refuel()
  59.     while not turtle.forward() do
  60.         turtle.dig()
  61.     end
  62. end
  63.  
  64. function refuel()
  65.     if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 10 then
  66.         print("Refuelling")
  67.         turtle.select(fuelIndex)
  68.         turtle.refuel(1)
  69.     end
  70. end
  71.  
  72. function fillInDirection(length, height, blockIndex)
  73.    
  74.     for h = 1, height do
  75.         --move to just before the end
  76.         for i = 1, length do
  77.             print("Moving to end of section")
  78.             forceMoveForward()
  79.         end
  80.        
  81.         --now move backwards, placing blocks
  82.         print("Placing row")
  83.         for l = 1, length do
  84.                 turtle.back()
  85.                 placeByIndex(blockIndex)
  86.         end
  87.        
  88.         print("Moving up for next section")
  89.         forceMoveUp()
  90.     end
  91.     print("Resetting height")
  92.     --reset to original position
  93.     for h = 1, height do
  94.         turtle.down()
  95.     end
  96. end
  97.  
  98. function placeByIndex(index)
  99.     turtle.select(index)
  100.     turtle.place()
  101. end
  102.  
  103. function buildRoom()
  104.     print("Building left wall")
  105.     fillInDirection(3,2,wallIndex) --left wall
  106.    
  107.     turtle.turnRight()
  108.     print("Building front wall")
  109.     fillInDirection(3,2,wallIndex) -- front wall
  110.    
  111.    
  112.     print("Adding door to front wall")
  113.     --clear the door part of the wall and place door
  114.     forceMoveRight()
  115.     forceMoveForward()
  116.     forceMoveForward()
  117.     forceTurnLeft() -- clear bottom half of door
  118.     forceMoveUp() -- clear top half of door
  119.     turtle.down()
  120.     turtle.back()
  121.     placeByIndex(doorIndex)
  122.    
  123.     --move to the end of the front wall on the right
  124.     turtle.turnRight()
  125.     forceMoveForward()
  126.     forceMoveForward()
  127.     forceTurnLeft()
  128.    
  129.     print("Building right wall")
  130.     fillInDirection(3,2,wallIndex) --right wall
  131.    
  132.     --move to place back wall
  133.     forceMoveRight()
  134.     forceMoveForward()
  135.     forceMoveForward()
  136.     forceMoveForward()
  137.     forceMoveForward()
  138.     forceTurnLeft()
  139.    
  140.     print("Building back wall")
  141.     fillInDirection(3,2,wallIndex) --back wall
  142.    
  143.     print("Building the roof")
  144.     forceMoveUp()
  145.     forceMoveUp()
  146.     forceMoveForward()
  147.     turtle.turnLeft()
  148.     for i = 1, 3 do
  149.         fillInDirection(3,1,roofIndex)
  150.         forceMoveRight()
  151.     end
  152.    
  153.     print("Moving inside")
  154.     for i = 1, 4 do
  155.         forceMoveForward()
  156.     end
  157.     forceMoveDown()
  158.     forceMoveDown()
  159.     forceMoveForward()
  160.     forceTurnLeft()
  161.     forceMoveForward()
  162.     turtle.turnLeft()
  163.     --now facing door
  164.     print("Facing door")
  165.     redstone.setOutput("front",4)
  166.     turtle.forward()
  167.    
  168.    
  169.     --forceMoveBack()
  170.     --fillInDirection(1,2,cornerIndex) -- corner
  171.    
  172. end
  173.  
  174. --Do the things
  175. buildRoom()
Advertisement
Add Comment
Please, Sign In to add comment