Jump to content
The simFlight Network Forums

Identifying the A/C Loaded Into FSX, & a Switch Offset Question


Recommended Posts

Hi Pete,

 

Couple of things…..

 

Is there a way to determine with a Lua script what aircraft has been loaded into FSX?  For example, I’m trying to find a way to detect if the currently loaded a/c in FSX is an A2A Cessna 172, or not.  I would like to be able to do this even if the a/c is not powered up. The atc_type entry in the aircraft.cfg file only returns Cessna, which could also indicate the default Cessna.  The only thing I can seem to find in the aircraft.cfg file that would help is the  ui_manufacturer=”A2A Cessna” entry but there is no offset for the ui_manufacturer field.  I tried reading the A2A 172 Mastery Battery Lvar hoping it would return a nil value if some other a/c was loaded, but this does not seem to be the case as a 0 was returned (same as battery off).  Any ideas appreciated.

 

Also...

 

While working on some Lua scripts I was a bit surprised to see the offsets for the Nav/GPS switch (0x132C) and Avionics Switch (0x2E80) are 4 bytes each even though they are just on and off (0 and 1) type variables, while the master battery switch offset (0x3102) is a single byte as I would have expected.  So I assume I should use ipc.readUD()  and ipc.writeUD() to manipulate the Nav/GPS and Avionics switches?

Is there something special about these "4 byte" switches that I need to take into account?

 

Thx,

Al

Link to comment
Share on other sites

Is there a way to determine with a Lua script what aircraft has been loaded into FSX?  For example, I’m trying to find a way to detect if the currently loaded a/c in FSX is an A2A Cessna 172, or not.  I would like to be able to do this even if the a/c is not powered up. The atc_type entry in the aircraft.cfg file only returns Cessna, which could also indicate the default Cessna.  The only thing I can seem to find in the aircraft.cfg file that would help is the  ui_manufacturer=”A2A Cessna” entry but there is no offset for the ui_manufacturer field

 

Use the aircraft name, from the "title" parameter in the aircraft.cfg file -- offset 3D00.  The title is how you select the aircraft in FS, and is the name used for FSUIPC's Profiles and Aircraft-specific settings.  It's the only unique identification for the aircraft (FS doesn't allow duplicates).

 

While working on some Lua scripts I was a bit surprised to see the offsets for the Nav/GPS switch (0x132C) and Avionics Switch (0x2E80) are 4 bytes each even though they are just on and off (0 and 1) type variables, while the master battery switch offset (0x3102) is a single byte as I would have expected.

 

It's historic. FSUIPC dates back to FS98 days, and then the offsets were actually offsets directly into an FS Module. All of the values identified were therefore in the sizes and units FS which FS used, directly.  Because one of the main purposes of FSUIPC was to allow applications written for FS98 (and later) to carry on working correctly in later versions of FS (FS2000, FS2002, FS2004, FSX, P3D) those original offsets are still the same, even if they don't need to be. The unused spaces in between were taken up with new values, and the size was increased from 8192 bytes (hex x0000-x1FFF)  to 65536 (x0000-xFFFF),. With the added ones like 3102, I could choose the size and units as needed, because now the offsets are NOT directly into FS but in memory maintained by FSUIPC whilst it ferrets them out (in the case of FS2004 nd before) or receives them from SimConnect (FSX and P3D).

 

So I assume I should use ipc.readUD()  and ipc.writeUD() to manipulate the Nav/GPS and Avionics switches?

 

You can use the Byte versions if you like, it really makes no difference in these cases because the only change from FALSE to TRUE is 0 to 1 in the first (lowest value) byte of the 4.

 

Pete

Link to comment
Share on other sites

Use the aircraft name, from the "title" parameter in the aircraft.cfg file -- offset 3D00.  The title is how you select the aircraft in FS, and is the name used for FSUIPC's Profiles and Aircraft-specific settings.  It's the only unique identification for the aircraft (FS doesn't allow duplicates).

........

 

Pete

Ah -- don't know how I missed seeing that offset.

Thanks very much,

Al

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.