Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Getting Coords
- print("What are my Coords?: ")
- io.write("X: ")
- CurrentX = tonumber(io.read())
- io.write("Z: ")
- CurrentZ = tonumber(io.read())
- print("What Are my Chest's Coords?: ")
- io.write("X: ")
- ChestX = tonumber(io.read())
- io.write("Z: ")
- ChestZ = tonumber(io.read())
- print("Which Direction am i facing?: ")
- CurrentDir = tonumber(io.read())
- -- getting ready to strip mine
- print("How many Tunnels?: ")
- Tunnels = tonumber(io.read())
- CompletedTunnels = 0
- print("How long is each tunnel?: ")
- TunnelLength = tonumber(io.read())
- if CurrentDir == 0 then
- DestZ = CurrentZ + TunnelLength
- DestX = CurrentX
- elseif CurrentDir == 1 then
- DestX = CurrentX - TunnelLength
- DestZ = CurrentZ
- elseif CurrentDir == 2 then
- DestZ = CurrentZ - TunnelLength
- DestX = CurrentX
- elseif CurrentDir == 3 then
- DestX = CurrentDir + TunnelLength
- DestZ = CurrentZ
- end
- function PathFind(Cx,Cz,Dx,Dz)
- --Checking Directions
- if Dx > Cx then
- while CurrentDir ~= 3 do -- POS x
- turtle.turnRight()
- if CurrentDir >= 3 then
- CurrentDir = 0
- else
- CurrentDir = CurrentDir + 1
- end
- end
- elseif Dx < Cz then
- while CurrentDir ~= 1 do -- NEG x
- turtle.turnRight()
- if CurrentDir >= 3 then
- CurrentDir = 0
- else
- CurrentDir = CurrentDir + 1
- end
- end
- end
- if CurrentDir == 1 or CurrentDir == 3 then
- while Cx ~= Dx do
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- if CurrentDir == 1 then
- Cx = Cx - 1
- elseif CurrentDir == 3 then
- Cx = Cx + 1
- end
- print("Current POS: ","X: "..Cx," Z: "..Cz)
- end
- else
- if Dz > Cz then
- while CurrentDir ~= 0 do -- POS z
- turtle.turnRight()
- if Current >= 3 then
- CurrentDir = 0
- else
- CurrentDir = CurrentDir + 1
- end
- end
- elseif Dz < Cz then
- while CurrentDir ~= 2 do -- NEG z
- turtle.turnRight()
- if Current >= 3 then
- CurrentDir = 0
- else
- CurrentDir = CurrentDir + 1
- end
- end
- end
- while Cz ~= Dz do
- while turtle.detectUp() do
- turtle.digUp()
- end
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- if CurrentDir == 0 then
- Cz = Cz + 1
- elseif CurrentDir == 2 then
- Cz = Cz - 1
- end
- print("Current POS: ","X: "..Cx," Z: "..Cz)
- end
- if Cx == Dx and Cz == Dz then
- return true
- end
- print("Destination POS: ","X: "..DestX,"Z: "..DestZ)
- -- Strip Mine
- while CompletedTunnels < Tunnels do
- PathFind(CurrentX,CurrentZ,DestX,DestZ) -- Current , Destination
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement