O3Bubbles09

Untitled

Sep 13th, 2012
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. args = {...}
  2.  
  3. rednet.open("right")
  4. cx,cy,cz = gps.locate(5,false)
  5. dx = args[1]
  6. dy = args[2]
  7. dz = args[3]
  8. print("Current:"..cx..","..cy..","..cz)
  9. print("Dest:"..dx..","..dy..","..dz)
  10.  
  11. distance = math.abs(dx-cx)
  12. print("Distance:"..distance)
  13.  
  14. while(distance>0) do
  15. if(turtle.detect()) then
  16. turtle.up()
  17. end
  18. turtle.forward()
  19. cx,cy,cz = gps.locate(5,false)
  20. if math.abs(dx-cx) >= distance then
  21. turtle.turnRight()
  22. end
  23.  
  24. distance = math.abs(dx-cx)
  25. print("Distance:"..distance)
  26. end
  27.  
  28. turtle.turnRight()
  29.  
  30. distance = math.abs(dz-cz)
  31. print("Distance:"..distance)
  32.  
  33. while(distance>0) do
  34. if(turtle.detect()) then
  35. turtle.up()
  36. end
  37. turtle.forward()
  38. cx,cy,cz = gps.locate(5,false)
  39. if math.abs(dz-cz) >= distance then
  40. turtle.turnRight()
  41. turtle.turnRight()
  42. end
  43.  
  44. distance = math.abs(dz-cz)
  45. print("Distance:"..distance)
  46. end
  47.  
  48. distance = math.abs(dy-cy)
  49. print("Distance:"..distance)
  50.  
  51. while(distance>0) do
  52. dir = dy-cy
  53. if dir>0 then
  54. turtle.up()
  55. else
  56. turtle.down()
  57. end
  58.  
  59. if turtle.detectUp() or turtle.detectDown() then
  60. print("Path blocked")
  61. return
  62. end
  63.  
  64. cx,cy,cz = gps.locate(5,false)
  65.  
  66. distance = math.abs(dy-cy)
  67. print("Distance:"..distance)
  68. end
  69.  
  70. print("Arrived at destination")
Advertisement
Add Comment
Please, Sign In to add comment