Advertisement
ardevlirn

computercraft turtle chemin

Jun 20th, 2014
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. -- startup: os.loadAPI("waypoint")
  2.  
  3.  
  4. function wayforward()
  5. turtle.select(2)
  6. return turtle.compareDown()
  7. end
  8. function wayleft()
  9. turtle.select(1)
  10. return turtle.compareDown()
  11. end
  12. function wayright()
  13. turtle.select(3)
  14. return turtle.compareDown()
  15. end
  16. function waystop()
  17. turtle.select(4)
  18. return turtle.compareDown()
  19. end
  20.  
  21. function go()
  22.  
  23. stop = false
  24.  
  25. print("slot 1 = left")
  26. print("slot 2 = forward")
  27. print("slot 3 = right")
  28. print("slot 4 = stop")
  29.  
  30. while stop ~= true do
  31.  
  32.  
  33. while wayforward() do
  34. turtle.forward()
  35. end
  36.  
  37. while wayleft() do
  38. turtle.turnLeft()
  39. turtle.forward()
  40. end
  41.  
  42. while wayright() do
  43. turtle.turnRight()
  44. turtle.forward()
  45. end
  46.  
  47. if waystop() == true then
  48. stop = true
  49. print("stop")
  50. end
  51.  
  52. end
  53.  
  54. end
  55.  
  56. function goback()
  57. stop = false
  58.  
  59.  
  60. while stop ~= true do
  61.  
  62. while wayforward() do
  63. turtle.forward()
  64. end
  65.  
  66. while wayleft() do
  67. turtle.turnRight()
  68. turtle.forward()
  69. end
  70.  
  71. while wayright() do
  72. turtle.turnLeft()
  73. turtle.forward()
  74. end
  75.  
  76. if waystop() == true then
  77. stop = true
  78. print("stop")
  79. end
  80.  
  81. end
  82.  
  83. end
  84.  
  85. function back()
  86. turtle.turnRight()
  87. turtle.turnRight()
  88. turtle.forward()
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement