Is there any way to detect from js at an early stage that we are in MSFS 2024 (or 2020)?
I had the same question but I was too shy to ask it
I think a variable that can tell us on which simulator we are on may be very useful. We could âswitch offâ functions that do not work in MSFS2024, or enable some that will only work on it.
It should be a function, not a variable because the variable system may not be initialized too early.
There is already GamePlateform() that returns âPCâ or âXBOXâ.
We could have something like GameVersion() that returns â2020â or â2024â.
For now, the only way I had to determine whether it was 2024 or 2020 was through some detailed file checking of both the 2020âs common.js
and the 2024âs common.js
, and look for any JS types (classes or functions) declared in the 2024âs common.js file, that are not available on the 2020âs. This is something I made for the EMB-110âs EFB which reports the MSFS version number. However, if the common.js
changes from 2024 eventually get backported to 2020, this would cause the detection not to work correctly, hence causing⊠letâs say⊠an âidentity crisisâ on either platform.
So, +1 for the idea from @ScorpionFilm422 of having a dedicated JS function declared that can help determine whether itâs 2024 or 2020.
Regards,
Carlos Daniel GonzĂĄlez GĂłmez
NextGen Simulations
We would also need to detect the MSFS SDK framework version (2020 or 2024) used to manage the flight plan in the cockpit.
BUMP.
weâre learning there are a lot of coding detail changes in MSFS2024 vs MSFS2020 (particularly anything to do with nav) and itâs crucial to be able to tell which sim youâre dealing with.
There must be some coding fragment that will reveal which sim is which, preferably using numeric simvars as thatâs about the only thing supported in common between the various programming environments. I have issues in simconnect mods and also issues in html/js gauges (we glider pilots are heavily invested in nav support). The only method for simconnect weâre trying so far is to get the Windows Task List and search that for MSFS 2024. Crazy eh?
Anyone got any idea using in-sim simvars?
I experimented with the ânewâ simvar âAIRCRAFT AGLâ which is in the 2024 sdk docs but not 2020, and discovered that simvar does actually exist in 2020. otherwise AIRCRAFT AGL = 0 would be a winner,
We definitely need a Simvar for it
We are finding this to be essential to deal with the differences between 2020 and 2024.
A SimVar would be ideal, for example SimVersion=1 for 2024
2020 would return 0 because the simvar wouldnât exist.
Versions after 2024 could be incremented.
Hope this can be added to help with the migration and, appreciate all the work done so far.
hey if a simvar can be designed from scratch, SIMVERSION = 1010700 gives us the whole â1.1.7.0â
still no official answer? due to large amount of differences between new and old sim, we have to apply exceptions anyhow. adding new simvar with static value is a 5 minutes deal.
best workaround I may think is try to enumerate some of the new variables. in FS2020 it returns 0, but such practice is dangerous as may cause unexpected result.
ENUM test = get_aircraft_var_enum("GENDER");
if (!test)
fprintf(stderr, "MSFS2020 DETECTED!\n");
else
fprintf(stderr, "MSFS2024 DETECTED!\n");
Minimal example in C++/WASM:
bool gIsMSFS2024;
void CALLBACK MyDispatchProc(SIMCONNECT_RECV* pData, DWORD cbData, void* pContext)
{
switch (pData->dwID)
{
case SIMCONNECT_RECV_ID_OPEN:
{
SIMCONNECT_RECV_OPEN* pOpen = (SIMCONNECT_RECV_OPEN*)pData;
const char* applicationName = pOpen->szApplicationName;
DWORD appVersionMajor = pOpen->dwApplicationVersionMajor;
gIsMSFS2024 = appVersionMajor == 12 ? true : false;
}