overshoot

Turtle Multi Branch Mine

Feb 16th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. print("Turtle Multiple Branch Mine #1")
  2.  
  3. print("Name: ", os.getComputerLabel() )
  4. print("Fuel Level: ", turtle.getFuelLevel())
  5.  
  6. function DigUp()
  7. print("Up")
  8. while turtle.detectUp()
  9. do turtle.digUp()
  10. sleep(0.4)
  11. end
  12. turtle.up()
  13. end --of DigUp
  14.  
  15. -- Dig Foward
  16. function DigFwd()
  17. print("Forward")
  18. while turtle.detect() do
  19. turtle.dig()
  20. sleep(0.4)
  21. end
  22. turtle.forward()
  23. end -- of Dig Fwd
  24.  
  25. -- DigDwn
  26. function DigDwn()
  27. print("Down")
  28. while turtle.detectDown()
  29. do turtle.digDown() end
  30. turtle.down()
  31. end -- of DigDown
  32.  
  33. -- Place torch
  34. function PlaceTorch()
  35. print("Place Torch")
  36. turtle.back()
  37. turtle.back()
  38. turtle.turnRight()
  39. turtle.select(16)
  40. turtle.placeUp()
  41. turtle.turnLeft()
  42. turtle.forward()
  43. turtle.forward()
  44. end -- of PlaceTorch
  45.  
  46. -- Dig a Segment and place torch
  47. function DigSegment(Length)
  48. for i=1,Length,1 do
  49. DigFwd()
  50. DigUp()
  51. DigFwd()
  52. DigDwn()
  53. end -- for loop for dig cycle
  54. end -- DigSegment function
  55.  
  56. -- Turn Back
  57. function TurnBack()
  58. turtle.turnLeft()
  59. DigFwd()
  60. DigUp()
  61. DigFwd()
  62. DigDwn()
  63. DigFwd()
  64. DigUp()
  65. turtle.down()
  66. PlaceTorch()
  67. turtle.turnLeft()
  68. end
  69. -- End Turn Back function
  70.  
  71. -- Start Another Branch
  72. function StartAnotherBranch()
  73. turtle.turnRight()
  74. turtle.forward()
  75. turtle.select(15)
  76. turtle.turnLeft()
  77. turtle.place()
  78.  
  79. if turtle.detect()
  80. then
  81. for slot=1,14,1 do
  82. turtle.select(slot)
  83. turtle.drop()
  84. end -- for each slot in inventory
  85. end -- If chest placed
  86.  
  87. turtle.turnRight()
  88. turtle.forward()
  89. turtle.forward()
  90. turtle.turnRight()
  91. end -- function StartAnotherBranch
  92.  
  93. ---------------------------
  94. -- Main Program
  95. NumSeg=2 -- Number of segments before turning back
  96. SegLen=4 -- Length of Segment between Torches
  97. NumBranch=3 -- Number of Branches to Mine
  98.  
  99. for branch=1,NumBranch,1 do
  100. for seg=1,NumSeg,1 do
  101. DigSegment(SegLen)
  102. PlaceTorch()
  103. end -- Distance to dig forward
  104.  
  105. TurnBack()
  106.  
  107. for seg=1,NumSeg,1 do
  108. DigSegment(SegLen)
  109. PlaceTorch()
  110. end -- Distance to dig back toward start
  111.  
  112. StartAnotherBranch()
  113. end -- for each branch to mine
Advertisement
Add Comment
Please, Sign In to add comment