Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. --[[
  2. Goals of the Mining Turtle:
  3. -Mine 2x1 mine shafts 54 blocks deep
  4. -Place torches to prevent mob spawning
  5. -Scan for ores (Hard to implement)
  6. -Drop Cobblestone, Sand, Dirt, and Gravel
  7. -Refuel as needed (Not needed yet)
  8. -Place items in a chest near the entrance of each shaft
  9. -Take in an input of the amount of shafts to build on one wall (Not yet)
  10. -Replace any walls as needed on the top or sides of the shaft
  11. -Return to start position when done.
  12. --]]
  13.  
  14. --Coordinates and Orientation
  15. startXCoord =
  16. startYCoord =
  17. startZCoord =
  18. xCoord = startXCoord
  19. yCoord = startYCoord
  20. zCoord = startZCoord
  21. orientation =
  22. orientations{0,1,2,3}
  23. xDiff = {-1,0-,1,0} --Changes in xCoord when moving in an orientation 0 = north
  24. zDiff = {0,1,0,-1} --Changes in yCoord when moving in an orientation 0 = north
  25.  
  26. --Movement Functions
  27. function left()
  28. orientation = orientation - 1
  29. orientation = (orientation - 1) % 4
  30. orientation = orientation + 1
  31. turtle.turnLeft()
  32. end
  33. function right()
  34. orientation = orientation - 1
  35. orientation = (orientation + 1) % 4
  36. orientation = orientation + 1
  37. turtle.turnLeft()
  38. end
  39. function look(direction)
  40. while direction ~= orientations[orientation]
  41. right()
  42. end
  43. end
  44. function moveForward()
  45. xCoord = xCoord + xDiff[orientation]
  46. zCoord = zCoord + zDiff[orientation]
  47. turtle.dig()
  48. moved = false
  49. while not(moved) do
  50. moved = turtle.forward()
  51. end
  52. end
  53. function moveUp()
  54. yCoord = yCoord + 1
  55. turtle.digUp()
  56. moved = false
  57. while not(moved) do
  58. moved = turtle.up()
  59. end
  60. end
  61. function moveDown()
  62. yCoord = yCoord - 1
  63. turtle.digUp()
  64. moved = false
  65. while not(moved) do
  66. moved = turtle.down()
  67. end
  68. end
  69. function moveTo(xTarget, yTarget, zTarget)
  70. while yCoord < yTarget do
  71. moveUp()
  72. end
  73. while yCoord > yTarget do
  74. moveDown()
  75. end
  76. if xCoord > xTarget then
  77. look(3)
  78. while xCoord > xTarget do
  79. moveForward()
  80. end
  81. end
  82. if xCoord < xTarget
  83. look(1)
  84. while xCoord < xTarget do
  85. moveForward()
  86. end
  87. end
  88. end
  89.  
  90. --Building the shaft functions
  91.  
  92. function placeTorch()
  93. turtle.select(16)
  94. turtle.placeDown()
  95. end
  96.  
  97. function digPortion()
  98. turtle.digUp()
  99. moveForward()
  100. turtle.digUp()
  101. moveForward()
  102. turtle.digUp()
  103. moveForward()
  104. moveUp()
  105. turnLeft()
  106. for i = 1, 5 do
  107. moveForward()
  108. end
  109. turnLeft()
  110. turnLeft()
  111. for i = 1, 10 do
  112. moveForward()
  113. end
  114. turnLeft()
  115. turnLeft()
  116. for i = 1, 5 do
  117. moveForward()
  118. end
  119. turnRight()
  120. moveDown()
  121. moveForward()
  122. end
  123.  
  124. function digUpToTorch()
  125. placeTorch()
  126. for i = 1, 3 do
  127. digPortion()
  128. end
  129. end
  130.  
  131. for i = 1, 4 do
  132. digUpToTorch()
  133. end
  134. digPortion()
  135. turtle.digUp()
  136. moveForward()
  137. turtle.digUp()
  138. moveForward()
  139. moveUp()
  140. for i = 1, 5 do
  141. moveForward()
  142. end
  143. moveTo(startXCoord, startYCoord, startZCoord)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement