ryzunTx

Untitled

Mar 4th, 2024
7
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.  
  9. http://davehendler.com/tracedata/
  10.  
  11. --]]
  12.  
  13. local tArgs = { ... }
  14.  
  15. if (#tArgs ~= 2) then
  16. print( "USAGE: stairs DIG_DEPTH STAIR_HEIGHT" )
  17. return
  18. end
  19.  
  20. depth=tonumber(tArgs[1])
  21. stairHeight=tonumber(tArgs[2])
  22.  
  23. fuelSlot = 1
  24. torchSlot = 2
  25.  
  26. torchEvery = 2
  27.  
  28. -- TODO: limit to rational sizes
  29.  
  30. t=turtle
  31.  
  32. climb = stairHeight-2
  33.  
  34. -- TODO: fuel management
  35.  
  36. t.select( fuelSlot )
  37. t.refuel( 1 )
  38.  
  39. for i = 1, depth do
  40. print( "Step " .. i .. " of " .. depth )
  41. print( "Fuel level: " .. t.getFuelLevel() )
  42.  
  43. -- move up to top of stair level
  44. for j = 1, climb do
  45. t.digUp()
  46. t.up()
  47. end
  48.  
  49. -- move in
  50. dug = t.dig()
  51. went = t.forward()
  52.  
  53. -- TODO: variable stair width
  54. -- TODO: place stairs blocks
  55. -- TODO: fill in empty spots?
  56.  
  57. -- dig out the stair
  58. for j = 1, stairHeight do
  59. t.turnLeft()
  60. t.dig()
  61. t.turnRight()
  62. t.turnRight()
  63. t.dig()
  64. t.turnLeft()
  65. -- Don't go down on last iteration
  66. if j ~= stairHeight then
  67. t.digDown()
  68. t.down()
  69.  
  70. -- TODO: check for empty spots to fill in
  71. end
  72.  
  73. -- Only place torches at the top
  74. if j == 1 then
  75. -- place torch every Nth level
  76. if 0 == i % torchEvery then
  77. t.select( torchSlot )
  78. t.placeUp()
  79. end
  80. end
  81. end
  82. end
Add Comment
Please, Sign In to add comment