Advertisement
dexman545

frameFlight

Jul 8th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. sd = "statusDoc"
  2. c = peripheral.wrap("left")
  3. down = 0
  4. up = 1
  5. north = 2
  6. south = 3
  7. west = 4
  8. east = 5
  9.  
  10. function sWrite()
  11. local sss = textutils.serialize(ss)
  12. local file = fs.open(sd, "w")
  13. file.write(sss)
  14. file.close()
  15. end
  16.  
  17. function sRead()
  18. local file = fs.open(sd, "r")
  19. ss = textutils.unserialize(file.readAll())
  20. return ss
  21. end
  22.  
  23. function getLoc()
  24. x, y, z = gps.locate(2, true)
  25. return x, y, z
  26. end
  27.  
  28. function yDis()
  29. getLoc()
  30. clear()
  31. yDis = y - tArgs[2]
  32. --ss = yDis
  33. --sWrite()
  34. end
  35.  
  36. function xDis()
  37. getLoc()
  38. clear()
  39. xDis = x - tArgs[1]
  40. --ss = xDis
  41. --sWrite()
  42. end
  43.  
  44. function zDis()
  45. getLoc()
  46. clear()
  47. zDis = z - tArgs[3]
  48. end
  49.  
  50. function clear()
  51. term.clear()
  52. term.setCursorPos(1,1)
  53. end
  54.  
  55. function moveY()
  56. sRead()
  57. Y = ss[2]
  58. if Y ~= 0 then
  59. if Y > 0 then
  60. ss[2] = Y - 1
  61. sWrite()
  62. sleep(1)
  63. c.move(down, false, false)
  64. elseif Y < 0 then
  65. ss[2] = Y + 1
  66. sWrite()
  67. sleep(1)
  68. c.move(up, false, false)
  69. end
  70. --else ss[2] = nil
  71. end
  72. end
  73.  
  74. function moveX()
  75. sRead()
  76. X = ss[1]
  77. if X ~= 0 then
  78. if X > 0 then
  79. ss[1] = X - 1
  80. sWrite()
  81. sleep(1)
  82. c.move(west, false, false)
  83. elseif X < 0 then
  84. ss[1] = X + 1
  85. sWrite()
  86. sleep(1)
  87. c.move(east, false, false)
  88. end
  89. --else ss[1] = nil
  90. end
  91. end
  92.  
  93. function moveZ()
  94. sRead()
  95. Z = ss[3]
  96. if Z ~= 0 then
  97. if Z > 0 then
  98. ss[3] = Z - 1
  99. sWrite()
  100. sleep(1)
  101. c.move(north, false, false)
  102. elseif Z < 0 then
  103. ss[3] = Z + 1
  104. sWrite()
  105. sleep(1)
  106. c.move(south, false, false)
  107. end
  108. --else ss[3] = nil
  109. end
  110. end
  111.  
  112. function getDis()
  113. xDis()
  114. yDis()
  115. zDis()
  116. --zDis = zDis - 1
  117. ss = {xDis, yDis, zDis}
  118. sWrite()
  119. end
  120.  
  121. clear()
  122.  
  123. tArgs = {...}
  124. if #tArgs < 1 then
  125. sRead()
  126. if ss[2] ~= 0 then
  127. moveY()
  128. elseif ss[1] ~= 0 then
  129. moveX()
  130. elseif ss[3] ~= 0 then
  131. moveZ()
  132. end
  133. print("not vaild location")
  134. else tArgs = {...}
  135. print(tArgs[1])
  136. print(tArgs[2])
  137. print(tArgs[3])
  138. sleep(5)
  139. getDis()
  140. moveY()
  141. moveX()
  142. moveZ()
  143. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement