Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- change mx for width, my for length and mz for height, the turtle will dig down and to the right
- mx = 100
- my = 100
- mz = 18
- -- Don't change anything bellow this line
- x = 1
- y = 1
- z = 1
- cx = 1
- cy = 1
- cz = 1
- posx = 1
- posy = 1
- function f()
- if turtle.forward() == false then
- repeat
- turtle.dig()
- sleep(0.25)
- until turtle.forward() == true
- end
- end
- function savepos()
- local f1=io.open("posx", "w")
- local f2=io.open("posy", "w")
- f1:write(cx)
- f2:write(cy)
- f1:close()
- f2:close()
- return true
- end
- function loadpos()
- local f1 = io.open("posx", "r")
- local f2 = io.open("posy", "r")
- posx = tonumber(f1:read())
- posy = tonumber(f2:read())
- f1:close()
- f2:close()
- end
- function d()
- if turtle.down() == false then
- repeat
- turtle.digDown()
- sleep(0.25)
- until turtle.down() == true
- end
- end
- function u()
- if turtle.up() == false then
- repeat
- turtle.digUp()
- sleep(0.25)
- until turtle.up() == true
- end
- end
- function check()
- for i = 1,15 do
- if turtle.getItemCount(i) == 0 then
- return true
- end
- end
- end
- function dropall()
- for dropSlot = 1,16 do
- turtle.select(dropSlot)
- turtle.drop()
- end
- turtle.select(1)
- turtle.turnRight()
- turtle.turnRight()
- end
- function down()
- while cz < mz do
- d()
- cz = cz+1
- end
- end
- function up()
- while cz > z do
- u()
- cz = cz-1
- end
- end
- function bdig()
- if cz == z and cx == x then
- goback()
- dropall()
- else
- up()
- goback()
- dropall()
- end
- end
- function refuel()
- end
- function goback()
- print("y - ",posy)
- print("x - ",posx)
- turtle.turnLeft()
- while cx > x do
- f()
- cx = cx - 1
- end
- turtle.turnLeft()
- while cy > y do
- f()
- cy = cy - 1
- end
- end
- function udig()
- while check() and cy < my do
- f()
- turtle.digUp()
- down()
- up()
- cy = cy+1
- savepos()
- end
- bdig()
- end
- while true do
- loadpos()
- if posx == x and posy ~= my then
- while cy < posy do
- f()
- cy = cy + 1
- end
- udig()
- elseif posx < mx and posy == my then
- turtle.turnRight()
- while cx < posx + 1 do
- turtle.digUp()
- f()
- cx = cx + 1
- end
- turtle.turnLeft()
- udig()
- elseif posx < mx and posy ~= my then
- turtle.turnRight()
- while cx < posx do
- turtle.digUp()
- f()
- cx = cx + 1
- end
- turtle.turnLeft()
- while cy < posy do
- turtle.digUp()
- f()
- cy = cy + 1
- end
- udig()
- elseif posy == my and posx == mx then
- print("Complete")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment