robocyclone

move

Feb 18th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. function forward(dirToGo)
  2. if dirToGo == "north" then
  3. y = y + 1
  4. if direction == "north" then
  5. turtle.forward()
  6. elseif direction == "south" then
  7. turtle.turnLeft()
  8. turtle.turnLeft()
  9. turtle.forward()
  10. elseif direction == "west" then
  11. turtle.turnRight()
  12. turtle.forward()
  13. elseif direction == "east" then
  14. turtle.turnLeft()
  15. turtle.forward()
  16. end
  17. direction = "north"
  18. elseif dirToGo == "east" then
  19. x = x + 1
  20. if direction == "north" then
  21. turtle.turnRight()
  22. turtle.forward()
  23. elseif direction == "west" then
  24. turtle.turnLeft()
  25. turtle.turnLeft()
  26. turtle.forward()
  27. elseif direction == "east" then
  28. turtle.forward()
  29. elseif direction == "south" then
  30. turtle.turnLeft()
  31. turtle.forward()
  32. end
  33. direction = "east"
  34. elseif dirToGo == "south" then
  35. y = y - 1
  36. if direction == "south" then
  37. turtle.forward()
  38. elseif direction == "north" then
  39. turtle.turnLeft()
  40. turtle.turnLeft()
  41. turtle.forward()
  42. elseif direction == "east" then
  43. turtle.turnRight()
  44. turtle.forward()
  45. elseif direction == "west" then
  46. turtle.turnLeft()
  47. turtle.forward()
  48. end
  49. direction = "south"
  50. elseif dirToGo == "west" then
  51. x = x - 1
  52. if direction == "west" then
  53. turtle.forward()
  54. elseif direction == "east" then
  55. turtle.turnLeft()
  56. turtle.turnLeft()
  57. turtle.forward()
  58. elseif direction == "south" then
  59. turtle.turnRight()
  60. turtle.forward()
  61. elseif direction == "north" then
  62. turtle.turnLeft()
  63. turtle.forward()
  64. end
  65. direction = "west"
  66. end
  67. fuel()
  68. end
Advertisement
Add Comment
Please, Sign In to add comment