local currentDirection = nil local warper = peripheral.wrap("right") rednet.open("left") function getCurrentDirection() local blockStatus, blockData = turtle.inspect() if (blockStatus == false) then local tp1X, tp1Y, tp1Z = gps.locate() turtle.forward() local tp2X, tp2Y, tp2Z = gps.locate() turtle.back() if (tp1X == tp2X) then if (tp1Z < tp2Z) then currentDirection = "South" else currentDirection = "North" end else if (tp1X < tp2X) then currentDirection = "East" else currentDirection = "West" end end else turtle.turnRight() getCurrentDirection() end end function turnLeft() if (currentDirection == "North") then currentDirection = "West" elseif (currentDirection == "West") then currentDirection = "South" elseif (currentDirection == "South") then currentDirection = "East" else currentDirection = "North" end turtle.turnLeft() end function turnRight() if (currentDirection == "North") then currentDirection = "East" elseif (currentDirection == "East") then currentDirection = "South" elseif (currentDirection == "South") then currentDirection = "West" else currentDirection = "North" end turtle.turnRight() end function warpToFuel() warper.savePoint("temp") warper.warpToPoint("refuel") getCurrentDirection() while (currentDirection ~= "North") do turnLeft() end local index = 1 while (index <= 16) do turtle.suck() index = index + 1 end warper.warpToPoint("temp") local blockStatus, blockData = turtle.inspect() while (blockData.name ~= "computercraft:turtle_advanced") do turtle.turnRight() blockStatus, blockData = turtle.inspect() end index = 1 while (index <= 16) do turtle.select(index) turtle.drop() index = index + 1 end end function warpToFuelSelf() warper.savePoint("temp") warper.warpToPoint("refuel") getCurrentDirection() while (currentDirection ~= "North") do turnLeft() end local index = 1 while (index <= 16) do turtle.suck() index = index + 1 end shell.run("refuel") turtle.turnRight() index = 1 while (index <= 16) do turtle.select(index) turtle.drop() index = index + 1 end os.sleep(1) warper.warpToPoint("temp") end while true do id, message = rednet.receive() if (message == "Refuel") then warpToFuelSelf() os.sleep(1) warpToFuel() rednet.send(49, "Refuel") local isWaiting = true while (isWaiting) do id, message = rednet.receive() if (message == "Continue Refuel") then warpToFuel() isWaiting = false rednet.send(49, "Finish Refuel") end end end end