Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pos = {0, 0, 0}
- local turn = 0
- local axis = 1
- function left()
- turtle.turnLeft()
- turn = turn - 1
- end
- function right()
- turtle.turnRight()
- turn = turn + 1
- end
- function forward()
- if not turtle.forward() then
- print("There is something in front of me")
- else
- if turn % 4 == 0 or turn % 4 == 1 then
- axis = 1
- else
- axis = -1
- end
- if turn % 4 == 1 or turn % 4 == 3 then
- pos[1] = pos[1] + axis
- else
- pos[2] = pos[2] + axis
- end
- end
- end
- function up()
- if not turtle.up() then
- print("There is something on top of me")
- else
- pos[3] = pos[3] + 1
- end
- end
- function down()
- if not turtle.down() then
- print("There is something underneath me")
- else
- pos[3] = pos[3] - 1
- end
- end
- if turtle.getFuelLevel() < 1 then
- turtle.refuel()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement