Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local startPoint = vector.new(gps.locate()
- local lastPoint = vector.new(gps.locate())
- local stop = false
- local light = true
- function refuel()
- if(turtle.getFuelLevel() < 100) then
- turtle.select(2)
- turtle.refuel(5)
- end
- end
- function torch()
- turtle.select(1)
- if(turtle.getItemCount() == 1)
- stop = true
- end
- turtle.placeUp()
- light = false
- end
- function clear()
- local i = 3
- while i < 17 do
- turtle.select(i)
- turtle.drop()
- i = i + 1
- end
- end
- function arm()
- for i=1,4 do
- turtle.dig()
- turtle.forward()
- end
- turtle.dig()
- end
- function armExit()
- for i=1,4 do
- turtle.forward()
- end
- end
- function way()
- local i = 0
- if(not(startPoint.x==lastPoint.x)) then
- local length = startPoint.x - lastpoint.x
- if(length<0) then
- length = -1*length
- end
- i = length
- elseif(not(startPoint.z==lastPoint.z)) then
- local length = startPoint.z - lastPoint.z
- if(length<0) then
- length = -1*length
- end
- i = length
- end
- return i
- end
- function move(length)
- for i=1,length do
- turtle.forward()
- end
- end
- do
- coroutine.create(refuel())
- while not stop do
- for i=1,3 do
- for i=1,4 do
- turtle.dig()
- turtle.forward()
- turtle.digUp()
- if(light and i==2) then
- torch()
- elseif(i==2)
- light = true
- end
- end
- turtle.turnLeft()
- turtle.up()
- arm()
- turtle.turnRight()
- turtle.turnRight()
- armExit()
- arm()
- turtle.turnRight()
- turtle.turnRight()
- armExit()
- turtle.turnRight()
- turtle.down()
- lastPoint = vector.new(gps.locate())
- end
- turtle.turnRight()
- turtle.turnRight()
- move(way())
- clear()
- turtle.turnRight()
- turtle.turnRight()
- move(way())
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement