Advertisement
Tatantyler

AutoMiner

Sep 8th, 2012
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.88 KB | None | 0 0
  1.     if not fs.exists("mt") then
  2.             shell.run("pastebin", "get", "Yt1u8zAu", "mt")
  3.     end
  4.      
  5.     if not fs.exists("persistent") then
  6.             shell.run("pastebin", "get", "n9DEEpaN", "persistent")
  7.     end
  8.      
  9.     os.loadAPI("mt")
  10.     shell.run("persistent")
  11.     appData = persistence.new("appData/turtleMiner2")
  12.     mt.main()
  13.     mt.load()
  14.  
  15. function debugInfo()
  16.     if appData.debug then
  17.     print("Persistence API:")
  18.     print("Recorded X:"..appData.x)
  19.     print("Recorded Y:"..appData.y)
  20.     print("Recorded Z:"..appData.z)
  21.     print("Home X:"..appData.homeX)
  22.     print("Home Y:"..appData.homeY)
  23.     print("Home Z:"..appData.homeZ)
  24.     print("Bucket X:"..appData.bucketX)
  25.     print("Bucket Y:"..appData.bucketY)
  26.     print("Bucket Z:"..appData.bucketZ)
  27.     print("MagicTurtle API:")
  28.     local x,y,z = mt.getPos()
  29.     print("Recorded X:"..x)
  30.     print("Recorded Y:"..y)
  31.     print("Recorded Z:"..z)
  32.     end
  33. end
  34.     local surfaceLevel = appData.returnToSurfaceLevel
  35.      
  36.     function verticalShaft()
  37.             while true do
  38.                     if turtle.detectDown() then
  39.                             local retries = 0
  40.                             while not turtle.digDown() do
  41.                                     retries = retries+1
  42.                                     if retries >= 5 then
  43.                                             return
  44.                                     end
  45.                             end
  46.                     end
  47.                     mt.down()
  48.             end
  49.     end
  50.      
  51.     function goToLevel(toY)
  52.             local x, y, z = mt.getPos()
  53.             mt.up(toY - y)
  54.     end
  55.      
  56.     if appData.nextLocation ~= nil then
  57.             mt.goToPos(appData.homeX,appData.homeY,appData.nextLocation)
  58.     end
  59.      
  60.     function dropOffMaterials()
  61.             mt.savePos()
  62.             if appData.doWaypoint then
  63.                     mt.goToPos(317, 88, 85, false)
  64.                     mt.setFacing(3)
  65.             end
  66.            
  67.             mt.goToPos(appData.bucketX, appData.bucketY, appData.bucketZ, false)
  68.             mt.savePos()
  69.             for i=1, 16 do
  70.                     turtle.select(i)
  71.                     turtle.dropDown()
  72.             end
  73.             turtle.select(1)
  74.             local x,y,z = mt.getPos()
  75.             mt.goToPos(x, appData.returnFlightLevel, z)
  76.            
  77.             mt.goToPos(appData.homeX,appData.returnFlightLevel,appData.z+1, true)
  78.             mt.savePos()
  79.     end
  80.      
  81.      
  82.     while true do
  83.         debugInfo()
  84.             appData.x,appData.y,appData.z = mt.getPos()
  85.             appData.positionFacing = mt.getFacing()
  86.             verticalShaft()
  87.             goToLevel(surfaceLevel)
  88.             appData.nextLocation = appData.z+1
  89.             dropOffMaterials()
  90.             appData.x,appData.y,appData.z = mt.getPos()
  91.             if appData.doRest then
  92.                     os.sleep(1)
  93.             end
  94.         debugInfo()
  95.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement