Slord6

Untitled

Jun 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.61 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 = Corners
  5. -- 3 = Door
  6. -- 4 = Chest
  7. -- 5 = Furnace
  8. -- 6 = Bed
  9.  
  10. -- 16 = Fuel
  11.  
  12. local wallIndex = 1
  13. local cornerIndex = 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 forceMoveRight()
  27.     turtle.turnRight()
  28.     forceMoveForward()
  29.     turtle.turnLeft()
  30. end
  31.  
  32. function forceMoveUp()
  33.     while not turtle.up() do
  34.         turtle.digUp()
  35.     end
  36. end
  37.  
  38. function forceMoveBack()
  39.     turtle.turnLeft()
  40.     turtle.turnLeft()
  41.     forceMoveForward()
  42.     turtle.turnLeft()
  43.     turtle.turnLeft()
  44. end
  45.  
  46. function forceMoveForward()
  47.     while not turtle.forward() do
  48.         turtle.dig()
  49.     end
  50. end
  51.  
  52. function refuel()
  53.     if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
  54.         print("Refuelling")
  55.         turtle.select(fuelIndex)
  56.         turtle.refuel(1)
  57.     end
  58. end
  59.  
  60. function fillInDirection(length, height, blockIndex)
  61.    
  62.     for h = 1, height do
  63.         --move to just before the end
  64.         for i = 1, length do
  65.             print("Moving to end of section")
  66.             forceMoveForward()
  67.         end
  68.        
  69.         --now move backwards, placing blocks
  70.         print("Placing row")
  71.         for l = 1, length do
  72.                 turtle.back()
  73.                 placeByIndex(blockIndex)
  74.         end
  75.        
  76.         print("Moving up for next section")
  77.         forceMoveUp()
  78.     end
  79.     print("Resetting height")
  80.     --reset to original position
  81.     for h = 1, height do
  82.         turtle.down()
  83.     end
  84. end
  85.  
  86. function placeByIndex(index)
  87.     turtle.select(index)
  88.     turtle.place()
  89. end
  90.  
  91. function buildRoom()
  92.     print("Building left wall")
  93.     fillInDirection(3,2,wallIndex) --left wall
  94.    
  95.     turtle.turnRight()
  96.     print("Building front wall")
  97.     fillInDirection(3,2,wallIndex) -- front wall
  98.    
  99.    
  100.     print("Adding door to front wall")
  101.     --clear the door part of the wall and place door
  102.     forceMoveRight()
  103.     turtle.forward()
  104.     turtle.forward()
  105.     forceTurnLeft() -- clear bottom half of door
  106.     forceMoveUp() -- clear top half of door
  107.     turtle.Down()
  108.     turle.back()
  109.     placeByIndex(doorIndex)
  110.    
  111.     --move to the end of the front wall on the right
  112.     turtle.turnRight()
  113.     turtle.forward()
  114.     turtle.forward()
  115.     forceTurnLeft()
  116.    
  117.     print("Building right wall")
  118.     fillInDirection(3,2,wallIndex) --right wall
  119.    
  120.     --move to place back wall
  121.     forceMoveRight()
  122.     turtle.forward()
  123.     turtle.forward()
  124.     turtle.forward()
  125.     turtle.forward()
  126.     forceTurnLeft()
  127.    
  128.     print("Building back wall")
  129.     fillInDirection(3,2,wallIndex) --back wall
  130.    
  131.    
  132.     --forceMoveBack()
  133.     --fillInDirection(1,2,cornerIndex) -- corner
  134.    
  135. end
  136.  
  137. --Do the things
  138. buildRoom()
Advertisement
Add Comment
Please, Sign In to add comment