Slord6

Untitled

Jun 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.88 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 = Crafting table
  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 craftIndex = 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.    
  122.     --move to the end of the front wall on the right
  123.     turtle.turnRight()
  124.     forceMoveForward()
  125.     forceMoveForward()
  126.     forceTurnLeft()
  127.    
  128.     print("Building right wall")
  129.     fillInDirection(3,2,wallIndex) --right wall
  130.    
  131.     --move to place back wall
  132.     forceMoveRight()
  133.     forceMoveForward()
  134.     forceMoveForward()
  135.     forceMoveForward()
  136.     forceMoveForward()
  137.     forceTurnLeft()
  138.    
  139.     print("Building back wall")
  140.     fillInDirection(3,2,wallIndex) --back wall
  141.    
  142.     print("Building the roof")
  143.     forceMoveUp()
  144.     forceMoveUp()
  145.     forceMoveForward()
  146.     turtle.turnLeft()
  147.     for i = 1, 3 do
  148.         fillInDirection(3,1,roofIndex)
  149.         forceMoveRight()
  150.     end
  151.    
  152.     print("Moving inside")
  153.     for i = 1, 4 do
  154.         forceMoveForward()
  155.     end
  156.     forceMoveDown()
  157.     forceMoveDown()
  158.     forceMoveForward()
  159.     forceTurnLeft()
  160.     forceMoveForward()
  161.     turtle.turnLeft()
  162.    
  163.     forceMoveForward() -- on the threshold
  164.     forceMoveForward()
  165.    
  166.     --clear front inside
  167.     forceMoveRight()
  168.     turtle.digUp()
  169.     forceMoveLeft()
  170.     turtle.digUp()
  171.     forceMoveLeft()
  172.     turtle.digUp()
  173.    
  174.     --clear middle inside
  175.     forceMoveForward()
  176.     forceMoveRight()
  177.     turtle.digUp()
  178.     forceMoveRight()
  179.     turtle.digUp()
  180.    
  181.     --clear back inside
  182.     forceMoveForward()
  183.     turtle.digUp()
  184.     forceMoveLeft()
  185.     turtle.digUp()
  186.     forceMoveLeft()
  187.     turtle.digUp()
  188.    
  189.     --place interior items
  190.     turtle.back()
  191.     turtle.back()
  192.     placeByIndex(bedIndex)
  193.     forceMoveRight()
  194.     turtle.forward()
  195.     placeByIndex(chestIndex)
  196.     forceMoveRight()
  197.     placeByIndex(craftIndex)
  198.    
  199.     --Lastly, place the door
  200.     forceMoveLeft()
  201.     turtle.back()
  202.     turtle.back()
  203.     turtle.back()
  204.     placeByIndex(doorIndex)
  205.    
  206.    
  207.     --forceMoveBack()
  208.     --fillInDirection(1,2,cornerIndex) -- corner
  209.    
  210. end
  211.  
  212. --Do the things
  213. buildRoom()
Advertisement
Add Comment
Please, Sign In to add comment