Jump to content
The simFlight Network Forums

Getting GPS information from Lua script


Recommended Posts

Hi,

I would like to get GPS information from a FSUIPC-started Lua script, but as far as I can see the FSUIPC offsets do not provide all information such as waypoints, nearby VORs,... Is there a way to obtain the necessary information?

Thanks!

-Djeez.

btw, I just recently discovered the Lua support from FSUIPC. This is awesome!

Link to comment
Share on other sites

I would like to get GPS information from a FSUIPC-started Lua script, but as far as I can see the FSUIPC offsets do not provide all information such as waypoints, nearby VORs,... Is there a way to obtain the necessary information?

The only way I can think of is to read the pathname for the loaded plan from offset 0130, and load that and decode it. That wouldn't give you "nearby VORs" though -- you'd need a data base for that.

Regards

Pete

Link to comment
Share on other sites

  • 1 year later...

The only way I can think of is to read the pathname for the loaded plan from offset 0130, and load that and decode it. That wouldn't give you "nearby VORs" though -- you'd need a data base for that.

Regards

Pete

Sorry I have to revive this issue. I stopped developing since I did not have a clue on how to proceed, but now I the issue pops up again.

The XML gauge facility can get to the information I need. The gps_500.xml that is part of FSX (it is in the gauges\fs9gps.cab file) is a good example. Somehow it manages to access the FSX database. Some of the code in this xml file:


<Macro Name="c">C:fs9gps</Macro>
<Macro Name="g">C:fs9gps</Macro>
...
<!-- update coords for the nearest pages -->
(A:GPS POSITION LAT, Radians) (>@c:NearestAirportCurrentLatitude, Radians) (A:GPS POSITION LON, Radians) (>@c:NearestAirportCurrentLongitude, Radians) 9 (>@c:NearestAirportMaximumItems) 200 (>@c:NearestAirportMaximumDistance, NMiles)
(A:GPS POSITION LAT, Radians) (>@c:NearestIntersectionCurrentLatitude, Radians) (A:GPS POSITION LON, Radians) (>@c:NearestIntersectionCurrentLongitude, Radians) 9 (>@c:NearestIntersectionMaximumItems) 200 (>@c:NearestIntersectionMaximumDistance, NMiles)
(A:GPS POSITION LAT, Radians) (>@c:NearestNdbCurrentLatitude, Radians) (A:GPS POSITION LON, Radians) (>@c:NearestNdbCurrentLongitude, Radians) 9 (>@c:NearestNdbMaximumItems) 200 (>@c:NearestNdbMaximumDistance, NMiles)
(A:GPS POSITION LAT, Radians) (>@c:NearestVorCurrentLatitude, Radians) (A:GPS POSITION LON, Radians) (>@c:NearestVorCurrentLongitude, Radians) 9 (>@c:NearestVorMaximumItems) 200 (>@c:NearestVorMaximumDistance, NMiles)
(A:GPS POSITION LAT, Radians) (>@c:NearestAirspaceCurrentLatitude, Radians) (A:GPS POSITION LON, Radians) (>@c:NearestAirspaceCurrentLongitude, Radians) (A:GPS POSITION ALT, Meters) (>@c:NearestAirspaceCurrentAltitude, Meters)

[/CODE]

(I just copied this code from the xml file, I have the feeling that this does the magic I need but I don't know how...)

Bob McElrath (http://www.robbiemcelrath.com/blackbox/?gps) wrote an extensive book on how this system works, but he only refers to XML gauges. In my case I want to display this information on Saitek panels and would like to use FSUIPC for that. As I know that the Lua library supports LVars, my hope is that maybe there is also a way to get to the information that is used by the XML gauges through the Lua extensions.

Thanks!

-Djeez.

Link to comment
Share on other sites

.... my hope is that maybe there is also a way to get to the information that is used by the XML gauges through the Lua extensions.

I think there is a way of getting into the GPS module from C/C++ as well as from XML. But it is an interface I am not currently familiar with, so it would require some research first. I may be able to look at it next year (I am away till mid-January in any case). It will not be trivial, maybe two or three weeks work, and I'm not really sure it is worth the effort. After all, it has been around for several versions of FS (not just FSX) but yours is the first ever request for it to be supported.

Remind me in mid to late January and I'll take a more serious look. Sorry, I don't have time beforehand.

BTW I am not going to do any more serious development work on FSUIPC3, only FSUIPC4. So I hope you are talking about FSX or Prepar3D.

Regards

Pete

Link to comment
Share on other sites

Remind me in mid to late January and I'll take a more serious look. Sorry, I don't have time beforehand.

BTW I am not going to do any more serious development work on FSUIPC3, only FSUIPC4. So I hope you are talking about FSX or Prepar3D.

Pete,

I very much appreciate your continous work on extending the FSUIPC capabilities. If you could have look into the GPS data that would be very kind indeed. No problem if that takes time. By the way, I have over 20 professional programming experience including C and C++ so if there is a way I could be of assistence then please feel free to ask.

I can only guess why I am the first person to ask... Maybe most applications (such as FSNavigator, FSCommander) need access to the whole navaid database and there is no other way to obtain that than by building a database from the bgl files. Other applications that I use such as AirTrack (connects FSX to an iPad) apparently use a real world database but that has the downside that it does not match the FSX scenery. Perhaps they just forgot to ask you! ;-)

This is for FSUIPC4 (FSX).

Best regards,

-Djeez.

Link to comment
Share on other sites

I can only guess why I am the first person to ask... Maybe most applications (such as FSNavigator, FSCommander) need access to the whole navaid database and there is no other way to obtain that than by building a database from the bgl files. Other applications that I use such as AirTrack (connects FSX to an iPad) apparently use a real world database but that has the downside that it does not match the FSX scenery. Perhaps they just forgot to ask you! ;-)

I didn't realise you were only interested in static information, not the full GPS capabilities.

If you only really want the static information which is fixed by the BGLs, why not use my freeware MakeRunways? Many of the sorts of add-ons you are talking about do. It only needs re-running when you update the scenery.

Pete

Link to comment
Share on other sites

I didn't realise you were only interested in static information, not the full GPS capabilities.

If you only really want the static information which is fixed by the BGLs, why not use my freeware MakeRunways? Many of the sorts of add-ons you are talking about do. It only needs re-running when you update the scenery.

I don't exactly understand what you mean with full GPS capabilities. My intention is to build a GPS-like display on a Saitek instrument panel where the user aircraft is displayed in with a sketch of the surrounding navaids and the flightplan. I probably could calculate the nearest navaids myself using MakeRunways (I have not used it before) and parse the flightplan file, but since all of this already done by FSX for the GPS.xml gauges, I thought maybe there is a possibility to hook into that.

Then (phase 2), I want to extend this with information on destination airport information and weather enroute.

Then (phase 3), I want to extend this with information on IVAO controllers online that are relevant for the flight.

My overall purpose is to display all information I need during flight on my Saitek displays and have my computer monitors only for outside view. In my opinion looking down on the flight instruments is so much more realistic than looking at the monitors for information.

-Djeez.

Link to comment
Share on other sites

I don't exactly understand what you mean with full GPS capabilities .... and the flightplan. I probably could calculate the nearest navaids myself using MakeRunways (I have not used it before) and parse the flightplan file, but since all of this already done by FSX for the GPS.xml gauges, I thought maybe there is a possibility to hook into that.

This is what i mean. You want to use the GPS in FSX, not make your own like, for example, the RealityXP GPS add-on gauges.

So you do want the full GPS interface, not just the static data which is certainly more readily available direct from compiled databases.

My overall purpose is to display all information I need during flight on my Saitek displays and have my computer monitors only for outside view. In my opinion looking down on the flight instruments is so much more realistic than looking at the monitors for information.

Yes. i have a full 737NG cockpit will all instrumentation and displays driven by separate PCs. FSX is only used for the flight model and the 3D scenery world. I also have a Piper GA cockpit with analogue instrumentation -- again no panel on the FS screen. But I Never got into GPS's on aircraft -- FMS and IRS on the 737 and good old raw VOR and NDB navigation on the GA aircraft! ;-)

I'll take a look at the GPS interface in January. If it isn't a lot of work I'll add it.

Regards

Pete

Link to comment
Share on other sites

  • 1 month later...

As you requested, this is a kind reminder for looking into the GPS interface.

Sorry, I thought I'd replied about two weeks ago, but I don't see it here. Odd.

I did some research on this and all I could find is ways of making a GPS gauge. It's a completely different sort of programming and it would be a completely separate module -- ideally a GAU file as that makes it easier to program by the look of it. Probably best written in XML. You could probably adapt an XML-written GPS module to copy all the values you want into L-Vars, then they would be accessible in Lua as it is.

I'm afraid none of this area of programming is something I've any experience with, and I really don't have the time nor motivation these days for learning something so new.

Sorry.

Regards

Pete

Link to comment
Share on other sites

Thanks for looking into it. I will look into your suggestion of using L-Vars. That is new to me. If I add a hidden gauge to a 2D aircraft panel, are then its L-vars accessible from Lua even if that panel is not displayed? Or are these gauges only accessible from Lua when shown?

-Djeez.

Link to comment
Share on other sites

Thanks for looking into it. I will look into your suggestion of using L-Vars. That is new to me. If I add a hidden gauge to a 2D aircraft panel, are then its L-vars accessible from Lua even if that panel is not displayed? Or are these gauges only accessible from Lua when shown?

No, if they are loaded they are running. visibility isn't relevant.

Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.