Advertisement
dlord

/miner/branchmine

Dec 26th, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. os.unloadAPI("/miner/movement")
  2. os.loadAPI("/miner/movement")
  3.  
  4. local length
  5. local torchPlacementInterval=7
  6. local maxRetryCount=20
  7.  
  8. function returnAfterRetryFailed()
  9. movement.move(0, 0, 0)
  10. movement.face("NORTH")
  11.  
  12. write("\Move retry count reached!\n")
  13. print("Did you reach bedrock?")
  14. error()
  15. end
  16.  
  17. function mineBlockAndMoveForward()
  18. local retryCount=0
  19. while movement.forward()==false do
  20. if retryCount>=maxRetryCount then
  21. returnAfterRetryFailed()
  22. end
  23.  
  24. if turtle.dig()==false then
  25. turtle.attack()
  26. end
  27.  
  28. retryCount=retryCount+1
  29. end
  30. end
  31.  
  32.  
  33. function placeTorch()
  34. turtle.select(1)
  35.  
  36. if turtle.placeDown()==false then
  37. movement.down()
  38. turtle.select(2)
  39. turtle.placeDown()
  40. movement.up()
  41.  
  42. turtle.select(1)
  43. turtle.placeDown()
  44. end
  45. end
  46.  
  47. function digDown()
  48. if turtle.detectDown() then
  49. turtle.digDown()
  50. sleep(0.200)
  51. end
  52. end
  53.  
  54. function branchmine(length)
  55. movement.up()
  56. for i=1,length do
  57. mineBlockAndMoveForward()
  58. digDown()
  59.  
  60. if i==1 or (i%torchPlacementInterval)==0 then
  61. placeTorch()
  62. end
  63. end
  64.  
  65. movement.move(0, 0, 1)
  66. movement.face("NORTH")
  67. movement.move(0, 0, 0)
  68. end
  69.  
  70. local args={...}
  71.  
  72. if #args >= 1 then
  73. length=tonumber(args[1])
  74. branchmine(length)
  75. else
  76. print("branchmine [length]")
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement