Advertisement
feedmecookies

GPS turtle

Jul 14th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. --define--
  2. x = 0
  3. y = 0
  4. z = 0
  5. tx = 0
  6. ty = 0
  7. tz = 0
  8. height = 200
  9. rotation = 1
  10. ----------
  11.  
  12. --functions--
  13. function rotate(w)
  14. while rotation ~= w do
  15. rotation = rotation + 1
  16. turtle.turnRight()
  17. if rotation == 5 then
  18. rotation = 1
  19. end
  20. end
  21. end
  22.  
  23. function GoX(cx,gx)
  24.  
  25. if cx > gx then
  26. rotate(4)
  27. for i = cx, gx + 1, -1 do
  28. turtle.forward()
  29. print("gox>")
  30. end
  31. elseif cx < gx then
  32. rotate(2)
  33. for i = cx, gx - 1 do
  34. turtle.forward()
  35. print("gox<")
  36. end
  37.  
  38. end
  39.  
  40. end
  41.  
  42. function GoY(cy,gy)
  43.  
  44. if cy > gy then
  45. for i = cy, gy - 1, -1 do
  46. turtle.down()
  47. print("goy>")
  48. end
  49. elseif cy < gy then
  50. for i = cy, gy - 1 do
  51. turtle.up()
  52. print("goy<")
  53. end
  54. end
  55. end
  56.  
  57. function GoZ(cz,gz)
  58. print("atleast it called")
  59. if cz > gz then
  60. rotate(1)
  61. for i = cz, gz+1, -1 do
  62. turtle.forward()
  63. print(i)
  64. end
  65. elseif cz < gz then
  66. rotate(3)
  67. for i = cz, gz - 1 do
  68. turtle.forward()
  69. print(i)
  70. end
  71. end
  72. end
  73.  
  74. function Drop()
  75. end
  76. -------------
  77.  
  78. --main--
  79. GoY(y,height)
  80. GoX(x,tx)
  81. GoZ(z,tz)
  82. GoY(height,ty)
  83. --------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement