Unable to read environment varibles native in MSFS 2024

Version: 1.5.4

Frequency: Consistently

Severity: Blocker

Bug description:
I understand you guys have deprecated the gauge.h apis, so I am trying to avoid using them at all cost and convert everything to the new MSFS_Vars API

Unfortunately, the new API is not capable of reading environmental variables (all the simvars that start with E, such as:

  • E:SIMULATION TIME
  • E:SIMULATION RATE
  • E:TIME OF DAY

And all others.

The 3 above are very important for custom systems simulation in WASM, simulation time is KEY! to have a clock in our modules for many reasons.

In MSFS 2020 WASM modules, I used execute_calculator_code to retrieve these environmental variables, however I can see you guys putting warnings on the documentation and also the gauge.h api:

[[deprecated("Panels API is now deprecated")]]
	BOOL FSAPI execute_calculator_code(PCSTRINGZ code, FLOAT64* fvalue, SINT32* ivalue, PCSTRINGZ* svalue);

If this is deprecated, then what is the new equivalent to retrieve the E:Vars? it makes no sense to deprecate functions if we do not have a way forward, so how I read these now? withouth these vars all my code cannot function properly.

I have included againg the gauge.h so I can read the vars, but I am worried because simply put, you guys could kill this at any time now and end up with none of my products working

Repro steps:

Try to retrieve Evars with the new vars API:

		FsVarParamArray param = FsCreateParamArray("i", 0);
		double result = 0;

		fsVarsAircraftVarGet(fsVarsGetAircraftVarId("E:SIMULATION TIME"), m_Units->Numbers, param, &result);

		FsDestroyParamArray(&param);

You get nothing.. same if you remove the E:PRefix.

This needs to be looked at before execute_calculator_code can be totally deprecated.

Best,
Raul

E: vars have dedicated API, I don’t think it’s made its way into documentation yet.

Check MSFS_Vars.h header:

FsEnvVarId fsVarsGetEnvironmentVarId(const char* name);
FsVarError fsVarsEnvironmentVarGet(FsEnvVarId id, FsUnitId unit, double* fvalue, int* ivalue);

2 Likes

Good lord, but that is not in the msfs documentation how you supposed to know? Lol.

R.

3 Likes

Doing it this way allowed me to read the vars natively withouth using the old gauges API.

Thank you.

2 Likes

Someone to the rescue!