Advertisement
Guest User

gps+

a guest
Jan 24th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1. vectors = {}
  2. function printUsage()
  3. print("Uses are gps+ set <name of waypoint>")
  4. print("or you can do gps+ go <waypoint>")
  5. end
  6.  
  7. local tArgs = {...}
  8.  
  9. if #tArgs < 1 then
  10. printUsage()
  11. return
  12. end
  13. local sCommand = tArgs[1]
  14. local detail = tArgs[2]
  15. if sCommand == "set" then
  16. x1,x2,x3 = gps.locate()
  17. print(gps.locate(9))
  18. print("gps Cords,",x1,',',x2,',',x3)
  19. x11 = toFloat(x1)
  20. x22 = toFloat(x2)
  21. x33 = toFloat(x3)
  22. --Above is to float below is tostring
  23. x1 = tostring(x1)
  24. x2 = tostring(x2)
  25. x3 = tostring(x3)
  26. --x4 = x1....x2....x3
  27.  
  28. --create addin code
  29. print(gps.locate())
  30. loc,loc1,loc2 = gps.locate()
  31. --lo1 = --loc..loc2--,loc2
  32. --print(loc,',',loc1)--,',loc2)
  33. strg = detail.." = "..loc..','..loc1..','..loc2
  34. --print(strg)
  35. h = fs.open("apps/gps+/vectorfile","a")
  36. h.writeLine(strg)
  37. h.close()
  38. --print(detail)
  39. --print(test)
  40.  
  41. elseif sCommand == "go" then
  42. print(detail)
  43. h = fs.open('apps/gps+/vectorfile','r')
  44. --f1 = h.readAll()
  45. f2 = string.find(h.readAll(),detail)
  46. if f2 then
  47. --vectorfile = os.loadAPI("apps/gps+/vectorfile")
  48. --print(vectorfile.test())
  49. print("returned true")
  50. print(detail)
  51. file = fs.open("apps/gps+/vectorfile",'r')
  52. for line in file.readAll():gmatch( "[^\n]+" ) do vectors[line:match( "[^=%s]+" )] = ( { line:match( "(%d+),(%d+),(%d+)" ) } ) end
  53. file.close()
  54. --print(table.foreach(vectors[detail],print))
  55. print("here is where it is supposed to be ",unpack(vectors[detail]))
  56. else
  57. print("couldn't find waypoint. Does it exist?")
  58. end
  59. elseif sCommand == "flush" then
  60. h = fs.open("apps/gps+/vectorfile",'w')
  61. h.flush()
  62. h.writeLine("-- Here is where gps+ stores your waypoints cords.")
  63. h.close()
  64. print("flush complete")
  65. else
  66. printUsage()
  67. end
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. --home = vector.new(-5321,76,-1383)
  75. --pos = gps.locate(2)
  76. --print("Your current Position is ",home)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement