Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1.  
  2. --[[
  3. Automated stair digger
  4. - Digs down DIG_DEPTH amount
  5. - Each stairs has a height of STAIR_HEIGHT
  6. - The top of every other stair will have a torch
  7. _ (If you place torches in inventory slot 2)
  8. http://davehendler.com/tracedata/
  9. --]]
  10.  
  11. local tArgs = { ... }
  12.  
  13. if (#tArgs ~= 2) then
  14. print( "USAGE: stairs DIG_DEPTH STAIR_HEIGHT" )
  15. return
  16. end
  17.  
  18. depth=tonumber(tArgs[1])
  19. stairHeight=tonumber(tArgs[2])
  20.  
  21. fuelSlot = 1
  22. torchSlot = 2
  23.  
  24. torchEvery = 2
  25.  
  26. -- TODO: limit to rational sizes
  27.  
  28. t=turtle
  29.  
  30. climb = stairHeight-2
  31.  
  32. -- TODO: fuel management
  33.  
  34. t.select( fuelSlot )
  35. t.refuel( 1 )
  36.  
  37. for i = 1, depth do
  38. print( "Step " .. i .. " of " .. depth )
  39. print( "Fuel level: " .. t.getFuelLevel() )
  40.  
  41. -- move up to top of stair level
  42. for j = 1, climb do
  43. t.digUp()
  44. t.up()
  45. end
  46.  
  47. -- move in
  48. dug = t.dig()
  49. went = t.forward()
  50.  
  51. -- TODO: variable stair width
  52. -- TODO: place stairs blocks
  53. -- TODO: fill in empty spots?
  54.  
  55. -- dig out the stair
  56. for j = 1, stairHeight do
  57. t.turnLeft()
  58. t.dig()
  59. t.turnRight()
  60. t.turnRight()
  61. t.dig()
  62. t.turnLeft()
  63. -- Don't go down on last iteration
  64. if j ~= stairHeight then
  65. t.digDown()
  66. t.down()
  67.  
  68. -- TODO: check for empty spots to fill in
  69. end
  70.  
  71. -- Only place torches at the top
  72. if j == 1 then
  73. -- place torch every Nth level
  74. if 0 == i % torchEvery then
  75. t.select( torchSlot )
  76. t.placeUp()
  77. end
  78. end
  79. end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement