Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. local tArgs = { ... }
  2. if #tArgs ~= 1 then
  3. print( "Usage: stairdown <length>. Place 1 cobble in slot 16, then stacks in the remainder of the inventory and ensure turtle has sufficient fuel." )
  4. return
  5. end
  6.  
  7. local depth = tonumber( tArgs[1] )
  8. if depth < 1 then
  9. print( "Stair depth must be positive" )
  10. return
  11. end
  12.  
  13. local forward = 0
  14. local down = 0
  15. local slot = 1
  16.  
  17. local function PlaceBlock()
  18. turtle.select(slot)
  19. for testSlot=1,15 do
  20. if turtle.compareTo(testSlot,16) then
  21. slot = testSlot
  22. return true
  23. end
  24. end
  25. if turtle.detectDown() then
  26. turtle.digDown()
  27. turtle.placeDown()
  28. else
  29. turtle.placeDown()
  30. end
  31. return true
  32. end
  33.  
  34. local function MoveForward()
  35. turtle.forward()
  36. forward = forward + 1
  37. return true
  38. end
  39.  
  40. local function MoveDown()
  41. turtle.down()
  42. down = down + 1
  43. return true
  44. end
  45.  
  46.  
  47. local function DigForward()
  48. if turtle.detect() then
  49. turtle.dig()
  50. MoveForward()
  51. else
  52. MoveForward()
  53. end
  54. return true
  55. end
  56.  
  57. local function DigDown()
  58. if turtle.detectDown() then
  59. turtle.digDown()
  60. MoveDown()
  61. else
  62. MoveDown()
  63. end
  64. return true
  65. end
  66.  
  67. local function StairDown()
  68. if turtle.detectDown() then
  69. turtle.digDown()
  70. MoveDown()
  71. PlaceBlock()
  72. else
  73. turtle.down()
  74. PlaceBlock()
  75. end
  76. return true
  77. end
  78.  
  79. --[[ while turtle.detectDown() do
  80. if turtle.digDown() then
  81. MoveDown()
  82. sleep(0.5)
  83. else
  84. return false
  85. end
  86. end
  87. return true
  88. ]]
  89.  
  90. print( "Making stairs..." )
  91. for n=1,depth do
  92. StairDown()
  93. DigForward()
  94.  
  95. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement