What is the best way to set a simvar in a C++ wasm module? I know there is the key events but there is no key event to write on some of the simvars (Avars). I am trying to force a bus voltage (A:ELECTRICAL MAIN BUS VOLTAGE:1 for instance) using execute_calculator_code() function but not successful. According to the SDK, ELECTRICAL MAIN BUS VOLTAGE is a settable simvar but there is no key event to set it.
my function that I am using is:
execute_calculator_code(“28 (>A:ELECTRICAL MAIN BUS VOLTAGE:1, Volts)”, nullptr, nullptr, nullptr);
please let me know if there is a possibility to directly write into a settable simvar with an index.
So technically this should work to set the voltage of a bus:1 to 28 volts:
execute_calculator_code(“28 (>A:ELECTRICAL MAIN BUS VOLTAGE:1, Volts)”, nullptr, nullptr, nullptr);
Are you quite certain that overriding the voltage can actually work? I am pretty sure that in a running aircraft simulation the voltage is handled by the aircraft code itself. There are many instances where that is the case. While you can technically set the value of a variable (doesn’t matter how you do it) - it holds that value only briefly - then the associated aircraft system resets it to the value that it is supposed to have.
Try a loop, set the value constantly as fast as you can. Maybe use a crazy value, so you can definitely see if something is happening. Then at least you know that setting the variable is working and/or futile (unless you keep the loop running)