Version: SU 15 - 1.37.4.0
Frequency: Consistently
Severity: High
Context: In flight, using any aircraft (third-party or default)
Bug description: When retrieving the value of a simvar (this also includes L:
vars) with the type boolean
[for example: (L:XMLVAR_MyBoolLocalVar, bool)
or (A:GPS DRIVES NAV1, bool)
] from JavaScript, through the SimVar.GetSimVarValue
function, that function returns either 0 or 1, and not true or false, as it used to happen before the SU15 flighting builds.
Repro steps: Below is a screenshot of the Coherent Debugger, showing the issue through the Debugger’s console. You can test not only there, but also from an HTML instrument.
I tested this behavior by sending the following code blocks into the Debugger’s console:
console.log(`SimVar AUTOPILOT AVAILABLE = ${SimVar.GetSimVarValue("AUTOPILOT AVAILABLE", "boolean")}`);
// returned "SimVar AUTOPILOT AVAILABLE = 1"
console.log(`SimVar IS IN VR = ${SimVar.GetSimVarValue("E:IS IN VR", "boolean")}`);
// returned "SimVar IS IN VR = 0"
console.log(`SimVar GPS DRIVES NAV1 = ${SimVar.GetSimVarValue("GPS DRIVES NAV1", "boolean")}`);
// returned "SimVar GPS DRIVES NAV1 = 1"
Then, I tested the following (as seen below):
Here, I tested with my current production build of my EMB-110 Bandeirante, because of the L:
var defined in the screenshot, but it is part of the example, as this also happens with local variables. Please pay attention to the following code block, replicating the same code “commands” sent to the Debugger’s console:
let testVar = SimVar.GetSimVarValue("L:XMLVAR_NGSE110_GPSGovernsCDI2", "Boolean");
console.log(testVar); // Returned 1 (for true) in my reproduction sample
// Now, let's negate that value
testVar = !testVar;
console.log(testVar); // When retrieving that var again, it returns false
// This means that the JS var declared here is no longer a Number and it became a boolean
// What if I negate it again?
testVar = !testVar;
console.log(testVar); // It returns true, and not 1 as before.
As I previously said, before this weird issue happened, the function used to correctly return a boolean
in JavaScript, but it’s not the case right now. Has something changed internally on that function?
Thank you very much in advance for your answer in this regard.
Regards,
Carlos Gonzalez
NextGen Simulations