local sArgs = ... local start = sArgs or "right" if start == "right" then start2 = "left" else start2 = "right" end faces = {} faces[0] = "north" faces[1] = "east" faces[2] = "south" faces[3] = "west" function init() if fs.exists("coords") then os.loadAPI("coords") x = coords.cX y = coords.cY z = coords.cZ face = coords.cFace distance = coords.cDistance print(x,y,z,face,distance) else x = 309 y = 2 z = 152 distance = 0 face = "north" face = tostring(face):lower() rewriteCoords() end shell.run("clear") print("requires 2 chunkLoaders in slot 14") print("requires 1 enderChest in slot 15") print("requires 1 bucket in slot 16") print("requires minimum 100 fuel") print(nil) print(x..", "..y..", "..z) print(face) while turtle.getFuelLevel() < 100 do local times = 0 turtle.refuel(64) sleep(.5) if times >= 25 then panic("Reinit: no fuel") end times = times + 1 end while true do local times = 0 for i=1,16 do turtle.select(i) local sel = turtle.getItemDetail() if sel and sel.name == "minecraft:bucket" then turtle.transferTo(16) elseif sel and sel.name == "EnderStorage:enderChest" then turtle.transferTo(15) elseif sel and sel.name == "ChickenChunks:chickenChunkLoader" then turtle.transferTo(14) end end local chunk = turtle.getItemDetail(14) local chest = turtle.getItemDetail(15) local bucket = turtle.getItemDetail(16) if chunk and chest and bucket then if chunk.name == "ChickenChunks:chickenChunkLoader" and chest.name == "EnderStorage:enderChest" and bucket.name == "minecraft:bucket" then break end end if times >= 25 then panic("Scattered Inventory") print("no stuff") end sleep(1) end end function upload(path) local file = fs.open( path, "r" ) local text = file.readAll() file.close() local response = http.post( "http://pastebin.com/api/api_post.php", "api_option=paste&".. "api_dev_key=ddfc115bf6e1cd0262ed53ee041c124b&".. "api_user_key=14fbf14a69d7c0652d52ce3dea8f7727&".. "api_paste_format=lua&".. "api_paste_name="..textutils.urlEncode(os.getComputerLabel()).."&".. "api_paste_code="..textutils.urlEncode(text) ) if response then print(response.readAll()) end end function panic(s) local h = fs.open("log","a") h.writeLine("SuperMiningTurtle(TM)") h.writeLine("ERROR!") h.writeLine("Coordinates: ("..x..", "..y..", "..z..")") h.writeLine("Distance: "..distance) h.writeLine("Direction: "..face) h.writeLine("Fuel: "..turtle.getFuelLevel()) h.writeLine("InvCount: "..checkIfFull()) h.writeLine("BucketSlot(16): "..turtle.getItemDetail(16).name) h.writeLine("ChestSlot(15): "..turtle.getItemDetail(15).name) h.writeLine("ChunkloaderSlot(14): "..turtle.getItemDetail(14).name) if s then h.writeLine([[Error Description: "]]..s..[["]]) end h.close() upload("log") textutils.slowPrint("ERROR") error() end function update() if face == "north" then z = z - 1 elseif face == "south" then z = z + 1 elseif face == "west" then x = x - 1 elseif face == "east" then x = x + 1 end rewriteCoords() end function updateFace(dir) if dir == "right" then if face == "north" then face = "east" elseif face == "east" then face = "south" elseif face == "south" then face = "west" elseif face == "west" then face = "north" end elseif dir == "left" then if face == "north" then face = "west" elseif face == "west" then face = "south" elseif face == "south" then face = "east" elseif face == "east" then face = "north" end end --for i = 0,3 do --if face == faces[i] then --if dir == "right" then --face = faces[(i + 1)%4] --elseif dir == "left" then --face = faces[(i + 3)%4] --end --end --end rewriteCoords() end function rewriteCoords() local h = fs.open("coords","w") h.writeLine("cX = "..x) h.writeLine("cY = "..y) h.writeLine("cZ = "..z) h.writeLine("cFace = \""..face.."\"") h.writeLine("cDistance = "..distance) h.close() os.loadAPI("coords") end function mine(dir) if dir == "left" or "right" then shell.run("go "..dir) updateFace(dir) cycle() shell.run("go "..dir) updateFace(dir) for i=1,4 do cycle() end else return end distance = distance + 1 end function cycle() local count = 0 turtle.dig() if not turtle.forward() then sleep(1) if not turtle.dig() then panic("stuck") print("stuck") else while not turtle.forward() do turtle.dig() end update() end else update() end turtle.digUp() turtle.digDown() if not turtle.detectDown() then turtle.select(16) if turtle.placeDown() then if not turtle.refuel(64) then turtle.placeDown() end end end end function checkInv() if turtle.getFuelLevel() < 1000 then shell.run("refuel") end if checkIfFull() == 16 then emptyInv() end if distance%16 == 0 or distance == 0 then loadChunks() end end function checkIfFull() local inv = 0 for i=1,16 do turtle.select(i) if turtle.getItemCount() > 0 then inv = inv + 1 end end return inv end function emptyInv() turtle.select(15) turtle.placeDown() for i = 1,13 do turtle.select(i) turtle.dropDown(64) end turtle.select(15) turtle.digDown() end function loadChunks() turtle.select(14) turtle.placeDown() if distance ~= 0 then local left, right = travelBack() turtle.select(14) turtle.digDown() shell.run("go right right") updateFace("right") updateFace("right") for i=1,16 do turtle.forward() update() end if not left then turtle.turnLeft() updateFace("left") else turtle.turnRight() updateFace("right") end end end function travelBack() turtle.turnRight() updateFace("right") local right = turtle.detect() turtle.turnLeft() updateFace("left") turtle.turnLeft() updateFace("left") local left = turtle.detect() turtle.turnRight() updateFace("right") if not left then turtle.turnLeft() updateFace("left") else turtle.turnRight() updateFace("right") end for i=1,16 do turtle.forward() update() end return left, right end init() checkInv() while true do mine(start) mine(start2) checkInv() end