Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. -- First set up computer #1.
  2. -- Create a program. Type in the following
  3. -- for i = 1,100 do
  4. -- rednet.open("right")
  5. -- id, message = rednet.receive()
  6. -- print ("Computer ".. id .. " has sent us a message")
  7. -- print ("The message is")
  8. -- print (message)
  9. -- end
  10.  
  11. isWireless = true
  12. consoleID = 11
  13. depth = 0
  14.  
  15. function fuel()
  16. if turtle.getFuelLevel() <= depth + 10 then
  17. turtle.select(16)
  18. turtle.refuel(1)
  19. if isWireless then rednet.send(consoleID,"Refueled. Fuel level: "..turtle.getFuelLevel()) end
  20. end
  21. end
  22.  
  23. function isValuable()
  24. if turtle.detect() == false then
  25. return false
  26. end
  27. for i=1,3 do
  28. turtle.select(i)
  29. if turtle.compare() then
  30. return false
  31. end
  32. end
  33. return true
  34. end
  35.  
  36. function checkWalls(dp)
  37. for j=1,4 do
  38. if isValuable() then
  39. if isWireless then rednet.send(consoleID,"Found ore at depth "..dp) end
  40. turtle.dig()
  41. end
  42. turtle.turnRight()
  43. end
  44. end
  45.  
  46. ------ ( Program Start ) ------
  47.  
  48. if isWireless == true then
  49. rednet.open("right")
  50. end
  51.  
  52. term.clear()
  53. term.setCursorPos(1,1)
  54. print("The Trololol Miner")
  55. print("-------------------------")
  56.  
  57. term.write("Start Mining? (y/n): ")
  58.  
  59. while read() == "y" do
  60.  
  61. depth = 0
  62. print("Commencing mining.")
  63. if isWireless then rednet.send(consoleID,"Commencing mining.") end
  64.  
  65. fuel()
  66. turtle.digDown()
  67. for st=1,2 do
  68. turtle.down()
  69. depth = depth + 1
  70. turtle.digDown()
  71. end
  72.  
  73. -- plug entrance hole
  74. turtle.select(15)
  75. turtle.placeUp()
  76.  
  77. while not turtle.detectDown() do
  78. fuel()
  79. turtle.down()
  80. depth = depth + 1
  81. if isWireless and depth%10==0 then
  82. rednet.send(consoleID,"At depth "..depth)
  83. end
  84. checkWalls(depth)
  85. turtle.digDown()
  86. end
  87.  
  88. if isWireless then rednet.send(consoleID,"Moving to next shaft location...") end
  89.  
  90. for mv=1,6 do
  91. fuel()
  92. turtle.up()
  93. depth = depth - 1
  94. end
  95.  
  96. -- move forward 2 blocks
  97. for z=1,2 do
  98. fuel()
  99. while not turtle.forward() do
  100. turtle.dig()
  101. sleep(.8)
  102. end
  103. end
  104.  
  105. -- turn right and move one block
  106. turtle.turnRight()
  107. fuel()
  108. while not turtle.forward() do
  109. turtle.dig()
  110. sleep(.8)
  111. end
  112. turtle.turnLeft()
  113.  
  114. -- go down to bedrock
  115. turtle.digDown()
  116. while not turtle.detectDown() do
  117. fuel()
  118. turtle.down()
  119. depth = depth + 1
  120. turtle.digDown()
  121. end
  122.  
  123. if isWireless then rednet.send(consoleID,"Returning to surface!") end
  124.  
  125. for k=depth,3,-1 do
  126. checkWalls(k)
  127. turtle.digUp()
  128. fuel()
  129. while not turtle.up() do
  130. turtle.digUp()
  131. sleep(.5)
  132. end
  133. if isWireless and k%10 == 0 then
  134. rednet.send(consoleID,"At depth "..k)
  135. end
  136. end
  137.  
  138. fuel()
  139. turtle.digUp()
  140. turtle.up()
  141. turtle.digUp()
  142. turtle.up()
  143.  
  144. -- fill exit hole
  145. turtle.select(15)
  146. turtle.placeDown()
  147.  
  148. turtle.forward()
  149. turtle.forward()
  150. turtle.turnRight()
  151. turtle.forward()
  152. turtle.turnLeft()
  153.  
  154. if isWireless then rednet.send(consoleID,"At the surface!") end
  155. term.write("Go on mining run? (y/n): ")
  156. end
  157.  
  158. print("Cancelled mining.")
  159.  
  160. if isWireless then rednet.close("right") end
  161. Computer
  162.  
  163. -- First set up computer #1.
  164. -- Create a program. Type in the following
  165. for i = 1,200 do
  166. rednet.open("right")
  167. id, message = rednet.receive()
  168. print ("Computer ".. id .. " has sent us a message:")
  169. print (message)
  170. print("-------------------------")
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement