Advertisement
Guest User

Untitled

a guest
Jul 25th, 2014
196
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.  
  16. local function PlaceBlock()
  17. turtle.select(slot)
  18. for testSlot=1,15 do
  19. if turtle.compareTo(testSlot,16) then
  20. slot = testSlot
  21. return true
  22. end
  23. end
  24. if turtle.detectDown() do
  25. turtle.digDown()
  26. turtle.placeDown()
  27. else
  28. turtle.placeDown()
  29. end
  30. return true
  31. end
  32.  
  33. local function MoveForward()
  34. turtle.forward()
  35. forward = forward + 1
  36. return true
  37. end
  38.  
  39. local function MoveDown()
  40. turtle.down()
  41. down = down + 1
  42. return true
  43. end
  44.  
  45.  
  46. local function DigForward()
  47. if turtle.detect() then
  48. turtle.dig()
  49. MoveForward()
  50. else
  51. MoveForward()
  52. end
  53. return true
  54. end
  55.  
  56. local function DigDown()
  57. if turtle.detectDown() then
  58. turtle.digDown()
  59. MoveDown()
  60. else
  61. MoveDown()
  62. end
  63. return true
  64. end
  65.  
  66. local function StairDown()
  67. if turtle.detectDown() then
  68. turtle.digDown()
  69. MoveDown()
  70. PlaceBlock()
  71. else
  72. turtle.down()
  73. PlaceBlock()
  74. end
  75. return true
  76. end
  77.  
  78. --[[ while turtle.detectDown() do
  79. if turtle.digDown() then
  80. MoveDown()
  81. sleep(0.5)
  82. else
  83. return false
  84. end
  85. end
  86. return true
  87. ]]
  88.  
  89.  
  90. local slot = 1
  91.  
  92.  
  93. print( "Making stairs..." )
  94. for n=1,depth do
  95. StairDown()
  96. DigForward()
  97.  
  98. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement