Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- path
- os.loadAPI("dig")
- --------------
- -- PATHING
- --------------
- local path = {}
- function forward()
- dig.forward()
- path[#path+1] = dig.forward
- end
- function back()
- dig.back()
- path[#path+1] = dig.back
- end
- function down()
- dig.down()
- path[#path+1] = dig.down
- end
- function up()
- dig.up()
- path[#path+1] = dig.up
- end
- function left()
- turtle.turnLeft()
- path[#path+1] = turtle.turnLeft
- end
- function right()
- turtle.turnRight()
- path[#path+1] = turtle.turnRight
- end
- function navigateBack()
- for i=#path,1,-1 do
- if path[i] == dig.forward then dig.back() end
- if path[i] == dig.back then dig.forward() end
- if path[i] == turtle.turnLeft then turtle.turnRight() end
- if path[i] == turtle.turnRight then turtle.turnLeft() end
- if path[i] == dig.up then dig.down() end
- if path[i] == dig.down then dig.up() end
- end
- end
- function navigateForward()
- for i=1,#path do
- path[i]()
- end
- end
- function clear()
- path = {}
- end
- function length()
- return #path
- end
- --------------
- --------------
- --------------
- function test()
- clear()
- forward()
- right()
- forward()
- forward()
- right()
- forward()
- left()
- forward()
- up()
- down()
- navigateBack()
- navigateForward()
- navigateBack()
- end
Advertisement
Add Comment
Please, Sign In to add comment