SoundChaos

Bedrock stairs

Aug 2nd, 2014
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. -- Initial Fueling
  2. turtle.refuel(1)
  3.  
  4. -- variable to tell main function when to stop
  5. local o = 1
  6.  
  7. -- Function to get the fuel level of the robot as a number
  8. fcount = function()
  9. return turtle.getFuelLevel()
  10. end
  11.  
  12. -- Move forward, Fuel Check and Refuel function
  13. forwardCheck = function()
  14. turtle.dig()
  15. turtle.forward()
  16.  
  17. if fcount() < 1 then
  18. turtle.select(1)
  19. print ("Attempting to eat my fuel...")
  20. if turtle.getItemCount(1) < 1 then
  21. print ("I am out of fuel...")
  22. o = 0
  23. end
  24. turtle.refuel(1)
  25. turtle.select(2)
  26. end
  27. end
  28.  
  29. downCheck = function()
  30. turtle.digDown()
  31. turtle.down()
  32.  
  33. if fcount() < 1 then
  34. turtle.select(1)
  35. print ("Attempting to eat my fuel...")
  36. if turtle.getItemCount(1) < 1 then
  37. print ("I am out of fuel...")
  38. o = 0
  39. end
  40. turtle.refuel(1)
  41. turtle.select(2)
  42. end
  43. end
  44.  
  45. -- Checks for bedrock and empty spaces
  46. bedCheck = function()
  47. turtle.digDown()
  48. if turtle.detectDown() then
  49. turtle.digDown()
  50. if turtle.detectDown() then
  51. o = 0
  52. end
  53. end
  54. end
  55.  
  56. -- Checks for lack of steps, and places blocks when needed. Uses slot 2 to place blocks
  57. checkNot = function()
  58. turtle.down()
  59. if not turtle.detectDown() then
  60. turtle.select(2)
  61. turtle.placeDown()
  62. turtle.select(1)
  63. turtle.up()
  64. else
  65. turtle.up()
  66. end
  67. end
  68.  
  69. dig = function()
  70. turtle.digUp() -- makes sure no block above
  71. bedCheck() -- digs down
  72. checkNot() -- makes sure there is solid step
  73. forwardCheck() -- move forward and digs if needed
  74. end
  75.  
  76. while o == 1 do
  77. turtle.turnLeft()
  78. turtle.dig()
  79. dig()
  80. turtle.dig()
  81. dig()
  82.  
  83. turtle.digUp()
  84. bedCheck()
  85. checkNot()
  86.  
  87. turtle.turnRight() -- after 3 spaces dug, turns right
  88. turtle.dig()
  89. forwardCheck() -- moves forward (digs if necessary)
  90. bedCheck() -- digs down
  91. downCheck() -- move to next layer of stairs (above by one block)
  92. bedCheck() -- cleans next layer
  93.  
  94.  
  95. turtle.turnRight() -- turns to start completing next layer
  96. turtle.dig()
  97. dig()
  98. turtle.dig()
  99. dig()
  100.  
  101. turtle.digUp()
  102. bedCheck()
  103. checkNot()
  104.  
  105. turtle.turnLeft()
  106. turtle.dig()
  107. forwardCheck() -- moves forward (digs if necessary)
  108. bedCheck() -- digs down
  109. downCheck() -- move to next layer of stairs (above by one block)
  110. bedCheck() -- cleans next layer
  111. end
Advertisement
Add Comment
Please, Sign In to add comment