Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --excavate--
- times = tonumber(read())
- mx = 0
- mz = 0
- my = 0
- x = 0
- y = 64 --where the refill pad is located--
- z = 0
- tx = 0
- ty = 30 --y level to start digging--
- tz = 0
- height = 30 --how high up you want the turtle to go to avoid digging through buildings on its way to the mine --
- ex = 5
- ez = 5 --quarry size--
- ey = 25 -- blocks deep --
- FuelCoefficent = 15 --oak plank = 15 and coal = 80--
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- Orientation = 1 --North = 1, East = 2, South = 3 and West = 4
- tempor = 0
- round = 1
- function refuel(amount)
- Rotate(2)
- while math.ceil((amount-turtle.getFuelLevel())/FuelCoefficent) >= 64 do
- turtle.suck(64)
- turtle.refuel(64)
- end
- if math.ceil((amount-turtle.getFuelLevel())/FuelCoefficent) > 0 then
- turtle.suck(math.ceil((amount-turtle.getFuelLevel())/FuelCoefficent))
- turtle.refuel(math.ceil((amount-turtle.getFuelLevel())/FuelCoefficent))
- end
- Rotate(1)
- end
- function GetOri()
- return Orientation
- end
- function SetOri(rot)
- Orientation = rot
- end
- function Rotate(rotation)
- if (Orientation == rotation-2) or (Orientation == rotation+2) then
- turtle.turnRight()
- turtle.turnRight()
- Orientation = rotation
- elseif(Orientation == 1 and rotation == 4 ) or (Orientation == rotation + 1) then
- turtle.turnLeft()
- Orientation = rotation
- elseif (Orientation == 4 and rotation == 1 ) or (Orientation == rotation - 1) then
- turtle.turnRight()
- Orientation = rotation
- end
- end
- function GoX(C,T)
- if C > T then
- Rotate(4)
- for i = T+1, C do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- elseif T > C then
- Rotate(2)
- for i = C+1, T do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- end
- function GoY(C,T)
- if C > T then
- for i = T+1, C do
- turtle.digDown()
- turtle.down()
- end
- elseif C < T then
- for i = C+1, T do
- digUp()
- turtle.up()
- end
- end
- end
- function GoZ(C,T)
- if C > T then
- Rotate(1)
- for i = T+1, C do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- elseif T > C then
- Rotate(3)
- for i = C+1, T do
- while turtle.detect() do
- turtle.dig()
- end
- turtle.forward()
- end
- end
- end
- function checkinv()
- tempor = GetOri()
- if turtle.getItemCount(16) ~=0 then
- GoX(tx+mx,tx)
- GoZ(tz+mz,tz)
- GoY(ty+my,height)
- GoX(tx,x)
- GoZ(tz,z)
- GoY(height,y)
- Rotate(3)
- for i = 1,16 do
- turtle.select(i)
- turtle.drop(64)
- end
- turtle.select(1)
- Rotate(2)
- print(math.abs(mx)+math.abs(mz)+math.abs(my)+math.abs(tx-x)+math.abs(tz-z)+math.abs(height -y)+math.abs(ty-height))
- refuel(2*(math.abs(mx)+math.abs(mz)+math.abs(my)+math.abs(tx-x)+math.abs(tz-z)+math.abs(height -y)+math.abs(ty-height)) + turtle.getFuelLevel())
- Rotate(1)
- GoY(y,height)
- GoX(x,tx)
- GoZ(z,tz)
- GoY(height,ty+my)
- GoX(tx,tx+mx)
- GoZ(tz,tz+mz)
- Rotate(tempor)
- end
- end
- function dig()
- checkinv()
- while turtle.detect() do
- turtle.dig()
- end
- if GetOri() == 1 then
- mz = mz-1
- elseif GetOri() == 2 then
- mx = mx+1
- elseif GetOri() == 3 then
- mz = mz+1
- elseif GetOri() == 4 then
- mx = mx-1
- end
- turtle.forward()
- end
- function excavate(x,y,z)
- Rotate(1)
- for p = 1, y do
- for i = 1, z do
- for o = 2, x do
- dig()
- end
- if GetOri() == 1 and i ~= z and round == 1 then
- Rotate(2)
- dig()
- Rotate(3)
- elseif GetOri() == 3 and i ~= z and round == 1 then
- Rotate(2)
- dig()
- Rotate(1)
- elseif GetOri() == 1 and i ~= z and round == 2 then
- Rotate(4)
- dig()
- Rotate(3)
- elseif GetOri() == 3 and i ~= z and round == 2 then
- Rotate(4)
- dig()
- Rotate(1)
- end
- end
- if round == 1 then
- round = 2
- Rotate(3)
- else
- round = 1
- Rotate(1)
- end
- checkinv()
- turtle.digDown()
- if p ~= ey then
- if turtle.down() == true then
- my = my - 1
- end
- end
- end
- end
- for i = 1, times do
- mx = 0
- mz = 0
- my = 0
- refuel(2*(math.abs(height - y)+math.abs(ty-height)+math.abs(tx-x)+math.abs(tz-z))+(ex*ez*ey)+ex+ez+ey)
- GoY(y,height)
- GoX(x,tx)
- GoZ(z,tz)
- GoY(height,ty+my)
- GoX(tx,tx+mx)
- GoZ(tz,tz+mz)
- excavate(ex,ey,ez)
- GoX(tx+mx,tx)
- GoZ(tz+mz,tz)
- GoY(ty+my,height)
- GoX(tx,x)
- GoZ(tz,z)
- GoY(height,y)
- Rotate(3)
- tz = tz - 5
- for i = 1,16 do
- turtle.select(i)
- turtle.drop(64)
- end
- turtle.select(1)
- Rotate(1)
- end
Add Comment
Please, Sign In to add comment