Advertisement
Guest User

gps+

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