Advertisement
Slord6

Untitled

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