Advertisement
TechOFreak

Minecraft Advanced Turtle Miner Program

Jan 5th, 2016
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.86 KB | None | 0 0
  1. --Follow the instructions below in order
  2. --You will need, 1 advanced mining turtle, 1 bc factory mining well, 1 tesseract from thermal expansion, 1 ender chest from ender storage, 2 chicken chunks chunk loaders, and some fuel for your turtle
  3. --Place down an advanced mining turtle high in the air away from obstacles facing some direction in a location of choice
  4. --Place a mining well from bc factory in front of the turtle
  5. --Place an ender chest from ender storage on top
  6. --Place a thermal expansion tesseract on top of the mining well and let the turtle collect items
  7. --Additionally put a fuel source inside of the turtles inventory like coal
  8. --Put 1 chunk loader from chicken chunks in the turtles inventory and now place down a chunk loader behide the turtle
  9. --Now run this program on the turtle
  10. --If all of the above steps are followed correctly then the turtle should automatically move itself forward along with all its items
  11. --It will also refuel itself constantly when its fuel level is below 50000 and also keep chunks loaded
  12.  
  13. function refuel()
  14.     fuel = turtle.getFuelLevel()
  15.     --Checks if fuel level has dropped below 50000, note the advanced turtles hold 100000 so this is 50%
  16.     print("Checking fuel level...")
  17.     print("Current fuel level is " .. fuel)
  18.     if fuel < 50000 then
  19.         position = 1
  20.         print("Fuel level " .. fuel .. " is below 50000")
  21.         print("Refueling...")
  22.        
  23.         while position < 17 do
  24.             turtle.select(position)
  25.             turtle.refuel()
  26.             position = position+1
  27.         end
  28.         fuel = turtle.getFuelLevel()
  29.     end
  30.     if fuel < 10 then
  31.         print("Fuel level too low to operate. Going to wait 10 seconds then check for fuel.")
  32.         os.sleep(10)
  33.         refuel()
  34.     end
  35.     print("Done refueling. Final fuel level is " .. fuel)
  36. end
  37.  
  38. function clean()
  39.     --Removes the mining well, the ender chest and the tesseract and then moves forward
  40.     print("Cleaning up...")
  41.     turtle.digUp()
  42.     turtle.dig()
  43.     turtle.up()
  44.     turtle.dig()
  45.     turtle.down()
  46.     print("Done cleaning. Now juggling chunk loaders...")
  47.    
  48.     notFound = true
  49.     while notFound do
  50.         position = 1
  51.         print("Looking for chunk loader...")
  52.         while position < 17 do
  53.             turtle.select(position)
  54.             if turtle.getItemCount(position) > 0 then
  55.                 --Nil check
  56.                 item = turtle.getItemDetail()
  57.                 if item ~= nil then
  58.                     if item.name == "ChickenChunks:chickenChunkLoader" then
  59.                         print("Chunk loader found!")
  60.                         notFound = false
  61.                         print("Placing and recyling old chunk loader...")
  62.                         turtle.placeUp()
  63.                         turtle.turnRight()
  64.                         turtle.turnRight()
  65.                         turtle.dig()
  66.                         turtle.back()
  67.                         notFoundTwo = true
  68.                         while notFoundTwo do
  69.                             positiontwo = 1
  70.                             print("Looking for chunk loader...")
  71.                             while positiontwo < 17 do
  72.                                 turtle.select(position)
  73.                                 if turtle.getItemCount(positiontwo) > 0 then
  74.                                     --Nil check
  75.                                     itemtwo = turtle.getItemDetail()
  76.                                     if itemtwo ~= nil then
  77.                                         if itemtwo.name == "ChickenChunks:chickenChunkLoader" then
  78.                                             print("Chunk loader found!")
  79.                                             notFoundTwo = false
  80.                                             print("Placing and recyling old chunk loader...")
  81.                                             turtle.place()
  82.                                             turtle.up()
  83.                                             turtle.dig()
  84.                                             turtle.turnRight()
  85.                                             turtle.turnRight()
  86.                                             print("Done recyling chunk loader!")
  87.                                             positiontwo = 16
  88.                                         end
  89.                                     end
  90.                                 end
  91.                                 positiontwo = positiontwo+1
  92.                             end
  93.                             if notFoundTwo then
  94.                                 print("Could not find chunk loader. Going to wait 10 seconds and then search again.")
  95.                                 os.sleep(10)
  96.                             end
  97.                         end
  98.                         print("Done recyling chunk loader!")
  99.                         position = 16
  100.                     end
  101.                 end
  102.             end
  103.             position = position+1
  104.         end
  105.         if notFound then
  106.             print("Could not find chunk loader. Going to wait 10 seconds and then search again.")
  107.             os.sleep(10)
  108.         end
  109.     end
  110.    
  111.     print("Done juggling chunk loaders!")
  112. end
  113.  
  114. function setup()
  115.    
  116.     --Self explanitory
  117.    
  118.     print("Setting up...")
  119.    
  120.     notFound = true
  121.     while notFound do
  122.         position = 1
  123.         print("Looking for tesseract...")
  124.         while position < 17 do
  125.             turtle.select(position)
  126.             if turtle.getItemCount(position) > 0 then
  127.                 --Nil check
  128.                 item = turtle.getItemDetail()
  129.                 if item ~= nil then
  130.                     if item.name == "ThermalExpansion:Tesseract" then
  131.                         turtle.place()
  132.                         position = 16
  133.                         print("Tesseract found!")
  134.                         notFound = false
  135.                     end
  136.                 end
  137.             end
  138.             position = position+1
  139.         end
  140.         if notFound then
  141.             print("Could not find tesseract. Going to wait 10 seconds and then search again.")
  142.             os.sleep(10)
  143.         end
  144.     end
  145.    
  146.     turtle.down()
  147.    
  148.     notFound = true
  149.     while notFound do
  150.         position = 1   
  151.         print("Looking for ender chest...")
  152.         while position < 17 do
  153.             turtle.select(position)
  154.             if turtle.getItemCount(position) > 0 then
  155.                 --Nil check
  156.                 item = turtle.getItemDetail()
  157.                 if item ~= nil then
  158.                     if item.name == "EnderStorage:enderChest" then
  159.                         turtle.placeUp()
  160.                         position = 16
  161.                         print("Ender chest found!")
  162.                         notFound = false
  163.                     end
  164.                 end
  165.             end
  166.             position = position+1
  167.         end
  168.         if notFound then
  169.             print("Could not find ender chest. Going to wait 10 seconds and then search again.")
  170.             os.sleep(10)
  171.         end
  172.     end
  173.    
  174.     notFound = true
  175.     while notFound do
  176.         position = 1
  177.         print("Looking for mining well...")
  178.         while position < 17 do
  179.             turtle.select(position)
  180.             if turtle.getItemCount(position) > 0 then
  181.                 --Nil check
  182.                 item = turtle.getItemDetail()
  183.                 if item ~= nil then
  184.                     if item.name == "BuildCraft|Factory:miningWellBlock" then
  185.                         turtle.place()
  186.                         position = 16
  187.                         print("Mining well found!")
  188.                         notFound = false
  189.                     end
  190.                 end
  191.             end
  192.             position = position+1
  193.         end
  194.         if notFound then
  195.             print("Could not find mining well. Going to wait 10 seconds and then search again.")
  196.             os.sleep(10)
  197.         end
  198.     end
  199.    
  200.     print("Done setting up!")
  201. end
  202.  
  203. function clearItems()
  204.     position = 1
  205.    
  206.     --Clears all items except for the chunk loader
  207.    
  208.     print("Clearing items...")
  209.     while position < 17 do
  210.         turtle.select(position)
  211.         if turtle.getItemCount(position) > 0 then
  212.             --Nil check
  213.             item = turtle.getItemDetail()
  214.             if item ~= nil then
  215.                 if item.name ~= "ChickenChunks:chickenChunkLoader" then
  216.                     turtle.dropUp()
  217.                 end
  218.             end
  219.         end
  220.         position = position+1
  221.     end
  222.    
  223.     print("Done clearing items!")
  224. end
  225.  
  226. function main()
  227.     refuel()
  228.     clearItems()
  229.     clean()
  230.     setup()
  231.     --Feel free to change this time for different heights
  232.     --When provided full power the mining well could dig roughly 10-12 blocks per second
  233.     --On the safe side do height/10 or if you want to cut it close and possibly clean up before the mining well is done then do height/12
  234.     --Tested at a height just below the clouds and a sleep time of 12 seems to work fine
  235.     print("Waiting for mining well to finish...")
  236.     os.sleep(12)
  237.     print("Done waiting!")
  238. end
  239.  
  240. while true do
  241.     main()
  242. end
  243.  
  244. --Changes in revision 1.3
  245. --Added an additional nil check due to nil values somehow getting past the first nil check
  246. --In game the turtle might find a few items that cause a nil index error thus the addition of the extra nil check
  247. --Now if the turtle can't find an item it will continue to search for it and will not do anything until the item is provided
  248. --Now if there is not enough fuel to operate the turtle will wait until enough fuel is provided
  249. --End changes in revision 1.3
  250.  
  251. --Changes in revision 1.2
  252. --Fixed typo in program causing the turtle not to turn
  253. --The turtle will now work in a line and will not move outside of the line and will not place blocks outside this line
  254. --End changes in revision 1.2
  255.  
  256. --Changes in revision 1.1
  257. --Fixed memory issue caused by infinite recursion
  258. --The chunk loader chould now be placed behind turtle rather than to the right
  259. --End changes in revision 1.1
  260.  
  261. --Program created by TechOFreak
  262. --Current program revision is 1.1
  263. --Feedback is welcomed
  264. --Visit my youtube channel at https://www.youtube.com/c/techofreak128
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement