Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = 0
- y = 0
- z = 0
- tx = -402
- ty = 200
- tz = -193
- function fuel()
- if turtle.getFuelLevel() == 0 then
- turtle.select(4)
- turtle.refuel()
- end
- end
- function up()
- fuel()
- while not turtle.up() do
- turtle.digUp()
- turtle.attackUp()
- end
- end
- function down()
- fuel()
- while not turtle.down() do
- turtle.digDown()
- turtle.attackDown()
- end
- end
- function forward()
- fuel()
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- end
- end
- function moveTo(x, y, z)
- dx = 0
- dy = 0
- dz = 0
- dir = 0 -- south
- while dy ~= y do
- if y > dy then
- up()
- dy = dy + 1
- end
- if y < dy then
- down()
- dy = dy - 1
- end
- end
- if dz > z then
- turtle.turnLeft()
- turtle.turnLeft()
- dir = 2
- end
- while dz ~= z do
- turtle.forward()
- if dir == 0 then
- dz = dz + 1
- else
- dz = dz - 1
- end
- end
- if dir == 0 then
- if x > dx then
- turtle.turnLeft()
- dir = 1
- elseif x < dx then
- turtle.turnRight()
- dir = 3
- end
- elseif dir == 2 then
- if x > dx then
- turtle.turnRight()
- dir = 1
- elseif x < dx then
- turtle.turnLeft()
- dir = 3
- end
- end
- while dx ~= x do
- turtle.forward()
- if dir == 3 then
- dx = dx + 1
- else
- dx = dx - 1
- end
- end
- end
- function nuke()
- turtle.digUp()
- turtle.digDown()
- turtle.select(5)
- turtle.placeUp()
- turtle.select(1)
- turtle.placeDown()
- turtle.select(2)
- turtle.dropDown()
- turtle.select(3)
- turtle.dropDown()
- rs.setOutput("down", true)
- rs.setOutput("up", true)
- end
- moveTo(tx - x, ty - y, tz - z)
- nuke()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement